Part Number Hot Search : 
80C31 ADM708S MICRO F15AR SMC170 AZ852 SAA71 431CH
Product Description
Full Text Search
 

To Download GMS87C7016K Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 HYNIX SEMICONDUCTOR INC. 8-BIT SINGLE-CHIP MICROCONTROLLERS
GMS81C7008 GMS81C7016
User's Manual (Ver. 2.01)
REVISION HISTORY
VERSION 2.01 (APR., 2001) This book Delete product of 52SDIP package also, no longer produce 52pin MCU. The compay name Hyundai Electronics Industires Co., Ltd. changed to Hynix Semiconductor Inc.
VERSION 2.00 (FEB., 2001) Delete product of 52LQFP package. Fixed some errata that pin number 25 and 26 on 52SDIP package are reversed. VERSION 1.02 (NOV., 2000) Fixed the name of LCR register on page 39 and 75, the BUR register on page 66. VERSION 1.01 (SEP., 2000) sticker Correct the bit LVDE of LVDR register on page 91.
Version 2.01 Published by MCU Application Team (c)2001 Hynix semiconductor Inc. All right reserved.
Additional information of this manual may be served by Hynix semiconductor offices in Korea or Distributors and Representatives listed at address directory. Hynix semiconductor reserves the right to make changes to any information here in at any time without notice. The information, diagrams and other data in this manual are correct and reliable; however, Hynix semiconductor is in no way responsible for any violations of patents or other rights of the third party generated by the use of this manual.
GMS81C7008/7016/7108/7116
Table of Contents
1. OVERVIEW............................................1
Description .........................................................1 Features .............................................................1 Development Tools ............................................2 Ordering Information ..........................................2
14. ANALOG DIGITAL CONVERTER .....57 15. SERIAL COMMUNICATION ..............59
Transmission/Receiving Timing ...................... 60 The method of Serial I/O ................................. 61 The Method to Test Correct Transmission ...... 61
2. BLOCK DIAGRAM .................................3 3. PIN ASSIGNMENT ................................4 4. PACKAGE DIMENSION ........................5 5. PIN FUNCTION......................................6 6. PORT STRUCTURES............................9 7. ELECTRICAL CHARACTERISTICS ....11
Absolute Maximum Ratings .............................11 Recommended Operating Conditions ..............11 DC Electrical Characteristics ...........................11 A/D Converter Characteristics .........................13 AC Characteristics ...........................................13 Serial Interface Timing Characteristics ............15 Typical Characteristics .....................................16
16. BUZZER FUNCTION .........................62 17. INTERRUPTS ....................................64
Interrupt Sequence .......................................... 66 BRK Interrupt .................................................. 67 Multi Interrupt .................................................. 67 External Interrupt ............................................. 68 Key Scan Interrupt .......................................... 68
18. LCD DRIVER .....................................70
LCD Control Registers .................................... 70 Duty and Bias Selection of LCD driver ............ 72 Selecting Frame Frequency ............................ 72 LCD Display Memory ...................................... 75 Control Method of LCD Driver ......................... 76
19. WATCH / WATCHDOG TIMER .........78
Watch Timer .................................................... 78 Watchdog Timer .............................................. 78
8. MEMORY ORGANIZATION.................18
Registers ..........................................................18 Program Memory .............................................21 Data Memory ...................................................24 List of Control Registers ...................................25 Addressing Mode .............................................28
20. POWER DOWN OPERATION...........81
SLEEP Mode ................................................... 81 STOP Mode .................................................... 82
9. I/O PORTS ...........................................32
Registers for Port .............................................32 I/O Ports Configuration ....................................33
21. OSCILLATOR CIRCUIT.....................85 22. RESET ...............................................86
External Reset Input ........................................ 86 Watchdog Timer Reset ................................... 86
10. CLOCK GENERATOR .......................37 11. OPERATION MODE ..........................39
Operation Mode Switching ...............................40
23. POWER FAIL PROCESSOR.............87 24. DEVELOPMENT TOOLS...................89
OTP Programming .......................................... 89 Emulator EVA. Board Setting .......................... 90
12. BASIC INTERVAL TIMER..................42 13. TIMER/EVENT COUNTER ................44
8-bit Timer / Counter Mode ..............................47 16-bit Timer / Counter Mode ............................51 8-bit Capture Mode ..........................................52 16-bit Capture Mode ........................................53 Timer output port mode ....................................53 PWM Mode ......................................................54
Appendix A. MASK ORDER SHEET .......................... i B. INSTRUCTION ...................................... ii
Terminology List .................................................ii Instruction Map .................................................. iii
APR., 2001 Ver 2.01
GMS81C7008/7016/7108/7116
Instruction Set ................................................... iv
C. SOFTWARE EXAMPLE ........................ x
APR., 2001 Ver 2.01
GMS81C7008/7016
GMS81C7008/16
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER WITH LCD DRIVER & A/D CONVERTER
1. OVERVIEW
1.1 Description
The GMS81C7008/7016 is advanced CMOS 8-bit microcontrollers with 8K/16K bytes of ROM. There are a powerful microcontroller which provides a highly flexible and cost effective solution to many LCD applications. These provide the following standard features:16K/ 8K bytes of mask type ROM or 16K bytes OTP ROM, 448 bytes of RAM, 8-bit timer/counter, 8-bit A/D converter, 10 bit high speed PWM Output, programmable buzzer driving port, 8-bit basic interval timer, watch dog timer, serial peripheral interface, on chip oscillator and clock circuitry. They also come with 4com/24seg LCD driver. In addition, it support power saving mode to reduce power consumption. Device name GMS81C7008 GMS81C7016 ROM Size 8K bytes 16K bytes RAM Size 448 bytes 448 bytes I/O 49 49 OTP GMS87C7016 GMS87C7016 Package 64SDIP, 64MQFP
1.2 Features
* 8K/16K Bytes On-chip Programmable ROM * 448 Bytes of On-chip Data RAM (Included stack area and 27 nibbles LCD Display RAM) * Instruction Execution Time 1s at 4MHz (2cycle NOP Instruction) * One 8-bit Basic Interval Timer * One Watch Timer * One Watchdog Timer * Four 8-bit Timer/Event Counter (or Two 16-bit Timer/Event Counter) * Two channel 10-bit High Speed PWM Output * Three External Interrupt input ports * One Programmable 6-bit Buzzer Driving port - 500Hz ~ 250kHz@4MHz * 49 I/O Ports * Eight channel 8-bit A/D converter * One 8-bit Serial Communication Interface * LCD Display/ Controller - Static Mode (27SEG x 1COM, Static) - 1/2 Duty Mode (26SEG x 2COM, 1/2 or 1/3 Bias) - 1/3 Duty Mode (25SEG x 3COM, 1/3 Bias) - 1/4 Duty Mode (24SEG x 4COM, 1/3 Bias) - Internal Built-in Resistor Circuit for Bias * Thirteen Interrupt sources - Basic Interval Timer: 1 - External input: 3 - Timer/Event counter: 4 - ADC: 1 - Serial Interface: 1 - WT:1 - WDT: 1 - Key Scan: 1 * Main Clock Oscillation (1.0~4.5MHz) - Crystal - Ceramic Resonator - External R Oscillator (Built-in Capacitor) * Sub Clock Oscillation - 32.768kHz Crystal Oscillator * Power Saving Operation Mode - Main / Sub Active mode changeable - 2/8/16/64 divided system clock selectable * Power Down Mode - STOP mode - SLEEP mode - Sub active Mode * 2.7V to 5.5V Wide Operating Voltage Range * Noise Immunity Circuit for EMS
APR., 2001 Ver 2.01
1
GMS81C7008/7016
- Power fail processor - Built in Noise filter * 64SDIP, 64LQFP package types
* Available 16K bytes OTP version
1.3 Development Tools
Windows 95/98TM.
Note: There are several setting switches in the Emulator. User should read carefully and do setting properly before developing the program refer to "24.2 Emulator EVA. Board Setting" on page 90. Otherwise, the Emulator may not work properly.
Please contact sales part of Hynix semiconductor.
Software Hardware (Emulator) OTP programmer
- MS- Window base assembler - Linker / Editor / Debugger - CHOICE-Dr. - CHOICE-Dr. EVA 81C51/81C7X B/D - CHOICE-SIGMA (Single type) - CHOICE-GANG4 (4-gang type)
The GMS81C7008/16 is supported by a full-featured macro assembler, an in-circuit emulator CHOICE-Dr.TM and OTP programmers. There are two different type programmers, one is single type, another is gang type. For more detail, refer to OTP Programming chapter. Macro assembler operates under the MS-
1.4 Ordering Information
Device name GMS81C7008 K GMS81C7016 K GMS81C7008 Q GMS81C7016 Q GMS87C7016 K GMS87C7016 Q ROM Size (bytes) 8K bytes 16K bytes 8K bytes 16K bytes 16K bytes OTP 16K bytes OTP RAM size 448 bytes 448 bytes 448 bytes 448 bytes 448 bytes 448 bytes Package 64SDIP 64SDIP 64MQFP 64MQFP 64SDIP 64MQFP
Mask ROM version
OTP ROM version
2
APR., 2001 Ver 2.01
GMS81C7008/7016
2. BLOCK DIAGRAM
GMS81C7008/7016
Common Drive Output COM0 COM1/SEG26 COM2/SEG25 COM3/SEG24 LCD Power Supply VCL0 VCL1 VCL2 BIAS LCD Power Control Circuit
Segment Drive Output SEG0 ~ SEG23
R40-R47 R50-R56 R60-R67
LCD Controller / Driver (LCDC)
R4
R5
R6
PSW
ALU
Accumulator
Stack Pointer
Data Memory LCD Display Memory
PC
Interrupt Controller RESET System controller System Clock Controller Timing generator XIN XOUT SXIN SXOUT High freq. Low freq. Clock Generator
Watch/ Watchdog
Program Memory Data Table
8-bit Basic Interval Tim er
PC High Speed PWM
Timer
8-bit A /D C onverter
8-bit SIO Timer/Counter
Key Scan
VDD VSS AVDD AVSS Power Supply
Power Supply Circuit
R3
Buzzer Driver
R2
R0
R1
R30 / BUZ R31 / PWM0 / T1O R32 / PWM1 / T3O R33 R34 / WDTO R35 / SXOUT R36 / SXIN
R20 / AN0 R21 / AN1 R22 / AN2 R23 / AN3 R24 / AN4 R25 / AN5 R26 / AN6 R27 / AN7
R00 / INT0 R01 / INT1 R02 / INT2 R03 / EC0 R04 / EC2 R05 / SCK R06 / SO R07 / SI
R10 R11
APR., 2001 Ver 2.01
3
GMS81C7008/7016
3. PIN ASSIGNMENT
64SDIP (Top View)
AN0 AN1 AN2 AN3
SXIN SXOUT AN4 AN5 AN6 AN7 SI SO SCK EC2 EC0 INT2 INT1 INT0 KS1 KS0 WDTO
VCL0 VCL1 VCL2 AVDD R20 R21 R22 R23 AVSS BIAS XIN XOUT RESET R36 R35 VSS R24 R25 R26 R27 R07 R06 R05 R04 R03 R02 R01 R00 R11 R10 R34 R33
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33
VDD COM3 COM2 COM1 COM0 SEG23 SEG22 SEG21 SEG20 SEG19 SEG18 SEG17 SEG16 SEG15 SEG14 SEG13 SEG12 SEG11 SEG10 SEG9 SEG8 SEG7 SEG6 SEG5 SEG4 SEG3 SEG2 SEG1 SEG0 R30 R31 R32
SEG24 SEG25 SEG26 R67 R66 R65 R64 R63 R62 R61 R60 R57 R56 R55 R54 R53 R52 R51 R50 R47 R46 R45 R44 R43 R42 R41 R40 BUZ PWM0 / T1O PWM1 / T3O
64MQFP (Top View)
51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33
SEG21 SEG20 SEG19 SEG18 SEG17 SEG16 SEG15 SEG14 SEG13 SEG12 SEG11 SEG10 SEG9 SEG8 SEG7 SEG6 SEG5 SEG4 SEG3
R65 R64 R63 R62 R61 R60 R57 R56 R55 R54 R53 R52 R51 R50 R47 R46 R45 R44 R43
GMS81C7008/7016
R66 R67 SEG26 SEG25 SEG24
4
SXIN SXOUT
AN4 AN5 AN6 AN7 SI SO SCK EC2 EC0
AN2 AN3
R22 R23 AVSS BIAS XIN XOUT RESET R36 R35 VSS R24 R25 R26 R27 R07 R06 R05 R04 R03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
AN0 AN1
SEG22 SEG23 COM0 COM1 COM2 COM3 VDD VCL0 VCL1 VCL2 AVDD R20 R21
52 53 54 55 56 57 58 59 60 61 62 63 64
GMS81C7008/7016
32 31 30 29 28 27 26 25 24 23 22 21 20
SEG2 SEG1 SEG0 R30 R31 R32 R33 R34 R10 R11 R00 R01 R02
R42 R41 R40 BUZ PWM0/T1O PWM1/T3O WDTO KS0 KS1 INT0 INT1 INT2
APR., 2001 Ver 2.01
GMS81C7008/7016
4. PACKAGE DIMENSION
64SDIP
UNIT: INCH
2.280 2.260 0.205 max. min. 0.015 0.750 Typ. 0.680 0.660
0.140 0.120
0.022 0.016
0.050 0.030
0.070 Typ.
0-15
0.012 0.008
64MQFP
24.15 23.65 20.10 19.90
UNIT: MM
18.15 17.65 14.10 13.90
0-7 SEE DETAIL "A" 0.36 0.10 1.03 0.73 1.95 REF 0.50 0.35 1.00 Typ. DETAIL "A"
3.18 max.
APR., 2001 Ver 2.01
0.23 0.13
5
GMS81C7008/7016
5. PIN FUNCTION
VDD: Supply voltage. VSS: Circuit ground. RESET: Reset the MCU. AVDD: Supply voltage to the ladder resistor of ADC circuit. To enhance the resolution of analog to digital converter, use independent power source as well as possible, other than digital power source. AVSS: ADC circuit ground. XIN: Input to the inverting oscillator amplifier and input to the internal main clock operating circuit. XOUT: Output from the inverting oscillator amplifier. BIAS: LCD bias voltage input pin. VCL0~VCL2: LCD driver power supply pins. The voltage on each pin is VCL2> VCL1> VCL0. For details, Refer to "18. LCD DRIVER" on page 70. COM0~COM3: LCD common signal output pins. Also, the pins of COM1,COM2 and COM3 are shared with LCD segment signal outputs of SEG26, SEG25, SEG24 as application requirement. SXIN: Input to the internal subsystem clock operating circuit. In addition, SXIN is shared with the R36 which is selected by the software option. SXOUT: Output from the inverting subsystem oscillator amplifier. In addition, SXOUT is shared with the R35 which is selected by the software option. R00~R07: R0 is an 8-bit CMOS bidirectional I/O port. R0 pins 1 or 0 written to the Port Direction Register can be used as outputs or schmitt trigger inputs. Also, pull-up resistors and open-drain outputs are software assignable. In addition, R0 serves the functions of the various following special features. Port pin R00 R01 R02 R03 R04 R05 R06 R07 Alternate function INT0 (External interrupt 0) INT1 (External interrupt 1) INT2 (External interrupt 2) EC0 (Event counter input 0) EC2 (Event counter input 2) SCK (Serial clock) SO (Serial data output) SI (Serial data input) ware assignable. These pins are not served on 81C71XX. In addition, R0 serves the functions of the various following special features. Port pin R00 R01 Alternate function KS0 (Key scan 0) KS1 (Key scan 1)
R20~R27: R2 is an 8-bit CMOS bidirectional I/O port. R2 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. Also, pull-up resistors and open-drain outputs are software assignable.R24~R27 are not served on 81C71XX. In addition, R2 is shared with the ADC input. Port pin R20 R21 R22 R23 R24 R25 R26 R27 Alternate function AN0 (Analog Input 0) AN1 (Analog Input 1) AN2 (Analog Input 2) AN3 (Analog Input 3) AN4 (Analog Input 4) AN5 (Analog Input 5) AN6 (Analog Input 6) AN7 (Analog Input 7)
R30~R36: R3 is a 7-bit CMOS bidirectional I/O port. R3 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. Also, pull-up resistors and open-drain outputs are software assignable. R33, R34 are not served on 81C71XX.
In addition, R3 serves the functions of the various following special features.
Port pin R30 R31 R32 R33 R34 R35 R36 Alternate function BUZ (Buzzer driving output) PWM0 / T1O (PWM 0 output / Timer 1 output) PWM1 /T3O (PWM 1 output / Timer 3 output) WDTO (Watchdog timer output) SXOUT (Sub clock output) SXIN (Sub clock input)
R10~R11: R1 is a 2-bit CMOS bidirectional I/O port. R1 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. Also, pull-up resistors and open-drain outputs are soft-
SEG0~SEG7: These pins generate LCD segment signal output. Every LCD segment pins are shared with normal R4 input/output port. R4 is an 8-bit CMOS bidirectional I/O port. R4 pins 1 or 0 written to the Port Direction Register can be used as outputs or in-
6
APR., 2001 Ver 2.01
GMS81C7008/7016
puts. LCD pin function SEG0 (LCD segment 0 signal output) SEG1 (LCD segment 1 signal output) SEG2 (LCD segment 2 signal output) SEG3 (LCD segment 3 signal output) SEG4 (LCD segment 4 signal output) SEG5 (LCD segment 5 signal output) SEG6 (LCD segment 6 signal output) SEG7 (LCD segment 7 signal output) Port pin R40 R41 R42 R43 R44 R45 R46 R47
SEG16~SEG23: These pins generate LCD segment signal output. Every LCD segment pins are shared with normal R6 input/output port. R6 is an 8-bit CMOS bidirectional I/O port. R6 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. LCD pin function SEG16 (LCD segment 16 signal output) SEG17 (LCD segment 17 signal output) SEG18 (LCD segment 18 signal output) SEG19 (LCD segment 19 signal output) SEG20 (LCD segment 20 signal output) SEG21 (LCD segment 21 signal output) SEG22 (LCD segment 22 signal output) SEG23 (LCD segment 23 signal output) Port pin R60 R61 R62 R63 R64 R65 R66 R67
SEG8~SEG15: These pins generate LCD segment signal output. Every LCD segment pins are shared with normal R5 input/output port. R5 is an 8-bit CMOS bidirectional I/O port. R5 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. LCD pin function SEG8 (LCD segment 8 signal output) SEG9 (LCD segment 9 signal output) SEG10 (LCD segment 10 signal output) SEG11 (LCD segment 11 signal output) SEG12 (LCD segment 12 signal output) SEG13 (LCD segment 13 signal output) SEG14 (LCD segment 14 signal output) SEG15 (LCD segment 15 signal output) Port pin R50 R51 R52 R53 R54 R55 R56 R57
APR., 2001 Ver 2.01
7
GMS81C7008/7016
PIN NAME (Alternate) VDD VSS RESET AVDD AVSS XIN XOUT BIAS VCL0~VCL2 COM0 COM1(SEG26) COM2(SEG25) COM3(SEG24) R00 (INT0) R01 (INT1) R02 (INT2) R03 (EC0) R04 (EC2) R05 (SCK) R06 (SO) R07 (SI) R10, R11(KS0, KS1) R20~R27(AN0~AN7) R30(BUZ) R31(PWM0 / T1O) R32(PWM1 / T3O) R33 R34(WDTO) R35(SXOUT) R36(SXIN) SEG0 ~ SEG7 (R40~R47) SEG8 ~ SEG15 (R50~R57) SEG16 ~ SEG23 (R60~R67)
In/Out (Alternate) I I O I I O O(O) O(O) O(O) I/O (I) I/O (I) I/O (I) I/O (I) I/O (I) I/O (I/O) I/O (O) I/O (I) I/O (I) I/O(I) I/O(O) I/O(O) I/O(O) I/O I/O(O) I/O(O) I/O(I) O (I/O) O (I/O) O (I/O) Supply voltage Circuit ground
Function Basic Alternate
Reset signal input Supply voltage input pin for ADC Ground level input pin for ADC Oscillation input Oscillation output LCD bias voltage input LCD driver power supply LCD common signal output
LCD common signal output
LCD segment signal output
External interrupt 0 input External interrupt 1 input External interrupt 2 input 8-bit general I/O ports Timer/Counter 0 external input Timer/Counter 1 external input Serial clock I/O Serial data output Serial data input 2-bit general I/O ports 8-bit general I/O ports Key scan input Analog voltage input Buzzer driving output PWM 0 output / Timer 1 output PWM 1 output / Timer 2 output 7-bit general I/O ports Watchdog timer output Sub clock output Sub clock input LCD segment signal output LCD segment signal output LCD segment signal output 8-bit general I/O ports 8-bit general I/O ports 8-bit general I/O ports
Table 5-1 Port Function Description
8
APR., 2001 Ver 2.01
GMS81C7008/7016
6. PORT STRUCTURES
R00/INT0, R01/INT1, R02/INT2, R03/EC0, R04/EC2, R05/SCK, R07/S
Pull up Reg. Open Drain Reg. Data Bus Data Reg. Pin VSS MUX RD Pull-up Tr.
R10~R11, R33, R35, R36
Pull up Reg. Open Drain Reg. Data Bus Pull-up Tr.
VDD
VDD
Data Reg. Pin VSS MUX RD
Dir. Reg.
Dir. Reg.
INT0 ~ INT2 EC0,EC2 SI,SCK
Noise Canceller
Tr.: Transistor Reg.: Register
RESET
VDD
R30/BUZ, R31/PWM0/T1O, R32/PWM1/T3O, R34/WDTO, R06
RESET Pull up Reg. VDD Open Drain Reg. Data Bus Data Reg. BUZ,SO,WDTO PWM0,PWM1 Dir. Reg. VSS Pin Pull-up Tr.
OTP MCU :disconnected Mask MCU :connected
Noise Canceller Internal RESET
OTP MCU :connected Mask MCU :disconnected
VSS VDD High Voltage On(OTP)
VSS
M UX
RD
SXIN, SXOUT R20/AN0~R27/AN7
Pull up Reg. Open Drain Reg. Data Bus Data Reg. Pin VSS MUX RD Sub clock OFF Internal System Clock Pull-up Tr. SXIN (R36) VDD VSS VDD SXOUT (R35) LCR.7=0
Dir. Reg.
AN0 ~ AN7
Analog Switch
APR., 2001 Ver 2.01
9
GMS81C7008/7016
R40~R47, R50~R57, R60~R67 / SEG0~SEG23
VDD Data Bus Data Reg.
XIN, XOUT
VDD
Dir. Reg. VSS MUX RD
Pin
XIN
XOUT
VSS STOP & Main Clock OFF VCL2 Main Clock
LCD Data VCL2 Enable VCL1 LCD Data VCL1 Enable LCD Data VCL0 Enable VCL0 LCD Data GND Enable VSS
COM0~COM3 / SEG24~SEG26
VCL2 LCD Data VCL2 Enable VCL1 LCD Data VCL1 Enable LCD Data VCL0 Enable VCL0 LCD Data GND Enable VSS
Pin
10
APR., 2001 Ver 2.01
GMS81C7008/7016
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
Supply voltage ........................................... -0.3 to +6.0 V Storage Temperature ................................-40 to +125 C Voltage on any pin with respect to Ground (VSS) ............................................................... -0.3 to VDD+0.3 Maximum current out of VSS pin ........................100 mA Maximum current into VDD pin ............................80 mA Maximum current sunk by (IOL per I/O Pin) ........20 mA Maximum output current sourced by (IOH per I/O Pin) ...............................................................................15 mA Maximum current (IOL) .................................... 100 mA Maximum current (IOH)...................................... 60 mA
Note: Stresses above those listed under "Absolute Maximum Ratings" may cause permanent damage to the device. This is a stress rating only and functional operation of the device at any other conditions above those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
7.2 Recommended Operating Conditions
Specifications Parameter Symbol Condition Min. Supply Voltage Operating Frequency Sub Operating Frequency Operating Temperature VDD fXIN fSXIN TOPR fXIN=4.19MHz fSXIN=32.768kHz VDD=2.7~5.5V VDD=2.7~5.5V 2.7 1 30 -20 Max. 5.5 4.5 35 +85 V MHz kHz C Unit
7.3 DC Electrical Characteristics
(TA=-20~85C, VDD=2.7~5.5V),
Specifications Parameter Symbol VIH1 VIH2 VIL1 VIL2 VOH1 VOH2 VOL1 VOL2 Input High Leakage Current IIH1 IIH2 Condition Min. RESET, R0 (except R06) Other pins RESET, R0 (except R06) Other pins R0,R1,R2,R3 IOH1=-0.5mA SEG, COM IOH2=-30A R0,R1,R2,R3 IOL1=0.4mA SEG, COM IOL2=30A VIN=VDD , All input pins except XIN, SXIN VIN=VDD, XIN, SXIN Input High Voltage 0.8 VDD 0.7 VDD 0 0 VDD-0.1 VDD-0.2 Typ. Max. VDD VDD 0.2 VDD 0.3 VDD 0.4 0.2 1 20 V V V V V V V V A A Unit
Input Low Voltage
Output High Voltage Output Low Voltage
APR., 2001 Ver 2.01
11
GMS81C7008/7016
Specifications Parameter Input Low Leakage Current Pull-up Resistor1 LCD Voltage Dividing Resistor Voltage Drop |VDD-COMn| , n=0~3 Voltage Drop |VDD-SEGn| , n=0~26 VCL2 Output Voltage VCL1 Output Voltage VCL0 Output Voltage RC Oscillation Frequency Symbol IIL1 IIL2 RPORT RLCD VDC VDS VCL2 VCL1 VCL0 fRC IDD1 IDD2 Supply Current1 ( ) means at 3V operation IDD3 IDD4 IDD5 IDD6 R=60k, VDD= 5V Main clock operation mode 2 VDD=5.5V10%, XIN=4MHz, SXIN=32kHz Sleep mode (Main active) 3 VDD=5.5V10%, XIN=4MHz, SXIN=32kHz Stop mode 2 VDD=5V10%, XIN= 0Hz, SXIN=32kH z Sub clock operation mode 4 VDD=5.5V10%, XIN=0Hz, SXIN=32kHz Sleep mode (Sub active)5 VDD=3V10%, XIN= 0Hz, SXIN=32kH z Stop mode4 VDD=5V10%, XIN= 0Hz, SXIN=0H z SXIN, SXOUT are used as R35, R36. VDD=2.7 ~ 5.5V, 1/3 bias BIAS pin and VCL2 pin are shorted Condition Min. VIN=0, All input pins except XIN, SXIN VIN=0, XIN, SXIN VIN=0V, VDD=5.5V, R0, R1, R2 VDD=5.5V VDD=2.7 ~ 5.5V -15A per common pin VDD=2.7 ~ 5.5V -15A per segment pin 60 45 VDD-0.3 0.66VDD -0.2 0.33VDD -0.3 1 Typ. 160 65 VDD 0.66VDD 0.33VDD 2 2.9 (1.3) 0.4 (0.1) 2.0 (1.0) 350 (70) 10 (3) 1.0 (0.5) Max. -1 -20 350 85 120 120 VDD+0.3 0.66VDD +0.3 0.33VDD +0.3 3 7.0 (3.0) 1.7 (1.0) 12 (5) 500 (200) 50 (20) 12 (5) MHz mA mA A A A A V A A k k mV mV Unit
-
1. Supply current in the following circuits are not included; on-chip pull-up resistors, internal LCD voltage dividing resistors, comparator voltage divide resistor, LVD circuit and output port drive currents. 2. This mode set System Clock Mode Register(SCMR) to xxxx0000B that is fXIN/2 3. This mode set SCMR to xxxx0000B (fXIN/2) and set SMR to "1". 4. Main-frequency clock stops and sub-frequency clock in not used and set SCMR to xxxx0011B. 5. Main-frequency clock stops and sub-frequency clock in not used, set SCMR to xxxx0011B and set SMR to "1".
12
APR., 2001 Ver 2.01
GMS81C7008/7016
7.4 A/D Converter Characteristics
(TA=25C, VSS=0V, VDD=5.0V, AVDD=5.0V @fXIN=4MHz)
Specifications Parameter Analog Input Voltage Range Non-linearity Error Differential Non-linearity Error Zero Offset Error Full Scale Error Gain Error Overall Accuracy AVDD Input Current Conversion Time Analog Power Supply Input Range Symbol VAIN NNLE NDNLE NZOE NFSE NGE NACC IREF TCONV AVDD VDD=5.0V VDD=3.0V VDD=AVDD=5.0V Test Condition Min. VSS-0.3 3.0 2.7 Typ.1 1.0 1.0 0.5 0.25 1.0 1.0 Unit Max. AVDD+0.3 1.5 1.5 1.5 0.5 1.5 1.5 200 20 VDD V LSB LSB LSB LSB LSB LSB A s V
1. Data in "Typ" column is at 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
7.5 AC Characteristics
(TA=-20~+85C, VDD=5V10%, VSS=0V)
Specifications Parameter Symbol fMAIN fSUB tMCPW tSCPW tMRCP,tMFCP tSRCP,tSFCP tMST tSST tIW tRST tECW Pins Min. Operating Frequency XIN SXIN XIN SXIN XIN SXIN XIN, XOUT at 4MHz SXIN, SXOUT INT0, INT1, INT2 RESET EC0, EC2 0.455 30 80 14.7 2 8 2 Typ. 32.768 0.5 Max. 4.2 35 20 3 20 1 MHz kHz nS S nS S mS S tSYS1 tSYS1 tSYS1 Unit
External Clock Pulse Width
External Clock Transition Time Main oscillation Stabilizing Time Sub oscillation Stabilizing Time Interrupt Pulse Width RESET Input Width Event Counter Input Pulse Width
1. tSYS is one of 2/fMAIN or 8/fMAIN or 16/fMAIN or 64/fMAIN in the main clock operation mode, tSYS is one of 2/fSUB or 8/fSUB or 16/fSUB or 64/fSUB in the sub clock operation mode.
APR., 2001 Ver 2.01
13
GMS81C7008/7016
1/fMAIN
tMCPW
tMCPW VDD-0.5V
XIN
tSYS 1/fSUB tMRCP tSCPW tMFCP tSCPW
0.5V
VDD-0.5V
SXIN
tSRCP tSFCP
0.5V
tIW
tIW
INT0, INT1 INT2
0.8VDD 0.2VDD
tRST
RESET
0.2VDD
tECW
tECW 0.8VDD 0.2VDD
EC0, EC2
Figure 7-1 Timing Chart
14
APR., 2001 Ver 2.01
GMS81C7008/7016
7.6 Serial Interface Timing Characteristics
(TA=-20~+85C, VDD=2.7~5.5V, VSS=0V, fXIN=4MHz)
Specifications Parameter Serial Input Clock Pulse Serial Input Clock Pulse Width SIN Input Setup Time (External SCK) SIN Input Setup Time (Internal SCK) SIN Input Hold Time Serial Output Clock Cycle Time Serial Output Clock Pulse Width Serial Output Clock Pulse Transition Time Serial Output Delay Time Symbol tSCYC tSCKW tSUS tSUS tHS tSCYC tSCKW tFSCK tRSCK sOUT Pins Min. SCK SCK SIN SIN SIN SCK SCK SCK SO 2tSYS+200 tSYS+70 100 200 tSYS+70 4tSYS tSYS-30 Typ. Max. 8 8 16tSYS 30 100 ns ns ns ns ns ns ns ns ns Unit
tFSCK 0.8VDD 0.2VDD
tSCYC tRSCK tSCKW tSCKW
SCLK
tSUS
tHS 0.8VDD 0.2VDD
SIN
tDS
SOUT
0.8VDD 0.2VDD
Figure 7-2 Serial I/O Timing Chart
APR., 2001 Ver 2.01
15
GMS81C7008/7016
7.7 Typical Characteristics
This graphs and tables provided in this section are for design guidance only and are not tested or guaranteed.
In some graphs or tables the data presented are outside specified operating range (e.g. outside specified VDD range). This is for information only and devices are guaranteed to operate properly only within the specified range.
The data presented in this section is a statistical summary of data collected on units from different lots over a period of time. "Typical" represents the mean of the distribution while "max" or "min" represents (mean + 3) and (mean - 3) respectively where is standard deviation
IOH (mA) Ta=25C -8
IOH-VOH, VDD=3.0V
IOH (mA) -20
IOH-VOH, VDD=5.0V
Ta=25C R (k) 200
RPU-Ta, VDD=5.0V R0,R1,R2,R3 pin
-6
-15
-4
-10
100
-2 0 0.5 1.0 1.5 2.0 2.5
-5 0 VOH (V) 0 1 2 3 4 VOH 5 (V) -20 0 40 80 Ta (C)
IOL (mA) 20
IOL-VOL, VDD=3.0V
Ta=25C
I -VOL, IOL OL (mA) Ta=25C
40
VDD=5.5V
fXIN (MHz) 4
fXIN-VDD
Ta=25C R = 6.2k R = 20k R = 60k
15
30
3
10
20
2
5 VOL (V)
10 0 1 2 3 4 VOL 5 (V)
1
R = 180k VDD 6 (V)
0 2 3 4 5
0.5
1.0 1.5
2.0
2.5
VIH1 (V) 4 3 2 1 0
VDD-VIH1 R0 (except R06)
fXIN=4MHz Ta=25C
VIH2 (V) 4 3 2 1
VDD-VIH2 R1~R6 pin (include R06)
fXIN=4MHz Ta=25C
VDD-VIH3
VIH1 (V) 4 3 2 1 fXIN=4MHz Ta=25C
XIN, SXIN
1
2
3
4
5
VDD 6 (V)
0 2 3 4 5
VDD 6 (V)
0 1 2 3 4 5
VDD 6 (V)
16
APR., 2001 Ver 2.01
GMS81C7008/7016
VIH1 (V) 4 3 2 1 0
VDD-VIL1 R0 (except R06)
fXIN=4MHz Ta=25C
VIH2 (V) 4 3 2 1
VDD-VIL2 R1~R6 pin (include R06)
fXIN=4MHz Ta=25C
VDD-VIL3
VIH1 (V) 4 3 2 1 fXIN=4MHz Ta=25C
XIN, SXIN
1
2
3
4
5
VDD 6 (V)
0 2 3 4 5
VDD 6 (V)
0 1 2 3 4 5
VDD 6 (V)
Normal Operation (Main opr.) IDD1-VDD
IDD (mA) 4 3 300 2 1 0 2 3 4 5 VDD 6 (V) 200 100 0 fXIN=4MHz Ta=25C IDD (A) 400
SLEEP Mode (Main opr.) ISLEEP(IDD2)-VDD -
fXIN=4MHz Ta=25C IDD (A) 4 3 2 1 VDD 6 (V) 0
STOP Mode ISTOP(IDD3)-VDD -
fXIN=0Hz Ta=25C
2
3
4
5
2
3
4
5
VDD 6 (V)
Normal Mode (Sub opr.) IDD4-VDD
IDD (A) 400 300 200 100 0 2 3 4 5 VDD 6 (V) fSXIN=32kHz Ta=25C IDD (A) 12 9 6 3 0
SLEEP Mode (Sub opr.) ISLEEP(IDD5)-VDD -
fSXIN=32kHz Ta=25C IDD (A) 4 3 2 1 VDD 6 (V) 0
STOP Mode ISTOP(IDD6)-VDD -
fSXIN=0Hz Ta=25C
2
3
4
5
2
3
4
5
VDD 6 (V)
APR., 2001 Ver 2.01
17
GMS81C7008/7016
8. MEMORY ORGANIZATION
The GMS81C7008/16 has separate address spaces for Program memory and Data Memory. Program memory can only be read, not written to. It can be up to 8K/16K bytes of Program memory. Data memory can be read and written to up to 448 bytes including the stack area and the LCD display RAM area.
8.1 Registers
This device has six registers that are the Program Counter (PC), a Accumulator (A), two index registers (X, Y), the Stack Pointer (SP), and the Program Status Word (PSW). The Program Counter consists of 16-bit register.
A X Y SP PCH PCL PSW
cess of the stack area permitted by the data memory allocating configuration, the user-processed data may be lost. The stack can be located at any position within 011BH to 01FFH of the internal data memory. The SP is not initialized by hardware, requiring to write the initial value (the location with which the use of the stack starts) by using the initialization routine. Normally, the initial value of "FFH" is used.
Bit 15 Stack Area (100H ~ 1FFH) 87 01H SP Hardware fixed SP (Stack Pointer) could be in 00H~FFH. LCD display RAM area is located in 100H~11AH, User must have concerning that Stack data does not cross over LCD RAM area. Bit 0 00H~FFH
ACCUMULATOR X REGISTER Y REGISTER STACK POINTER PROGRAM COUNTER PROGRAM STATUS WORD
Figure 8-1 Configuration of Registers Accumulator: The Accumulator is the 8-bit general purpose register, used for data operation such as transfer, temporary saving, and conditional judgement, etc. The Accumulator can be used as a 16-bit register with Y Register as shown below.
Y Y A Two 8-bit Registers can be used as a "YA" 16-bit Register A
Note: The Stack Pointer must be initialized by software because its value is undefined after RESET. Example: To initialize the SP LDX #0FFH TXSP
; SP FFH
Figure 8-2 Configuration of YA 16-bit Register X, Y Registers: In the addressing mode which uses these index registers, the register contents are added to the specified address, which becomes the actual address. These modes are extremely effective for referencing subroutine tables and memory tables. The index registers also have increment, decrement, comparison and data transfer functions, and they can be used as simple accumulators. Stack Pointer: The Stack Pointer is an 8-bit register used for occurrence interrupts and calling out subroutines. Stack Pointer identifies the location in the stack to be access (save or restore). Generally, SP is automatically updated when a subroutine call is executed or an interrupt is accepted. However, if it is used in ex-
Program Counter: The Program Counter is a 16-bit wide which consists of two 8-bit registers, PCH and PCL. This counter indicates the address of the next instruction to be executed. In reset state, the program counter has reset routine address (PCH:0FFH, PCL:0FEH). Program Status Word: The Program Status Word (PSW) contains several bits that reflect the current state of the CPU. The PSW is described in Figure 8-3. It contains the Negative flag, the Overflow flag, the Break flag the Half Carry (for BCD operation), the Interrupt enable flag, the Zero flag, and the Carry flag. [Carry flag C] This flag stores any carry or not borrow from the ALU of CPU after an arithmetic operation and is also changed by the Shift Instruction or Rotate Instruction. [Zero flag Z] This flag is set when the result of an arithmetic operation or data transfer is "0" and is cleared by any other result.
18
APR., 2001 Ver 2.01
GMS81C7008/7016
PSW NEGATIVE FLAG OVERFLOW FLAG SELECT DIRECT PAGE when G=1, page is selected to "page 1" BRK FLAG
MSB NVGBH
I
Z
LSB C RESET VALUE: 00H CARRY FLAG RECEIVES CARRY OUT ZERO FLAG INTERRUPT ENABLE FLAG HALF CARRY FLAG RECEIVES CARRY OUT FROM BIT 1 OF ADDITION OPERLANDS
Figure 8-3 PSW (Program Status Word) Register [Interrupt disable flag I] This flag enables/disables all interrupts except interrupt caused by Reset or software BRK instruction. All interrupts are disabled when cleared to "0". This flag immediately becomes "0" when an interrupt is served. It is set by the EI instruction and cleared by the DI instruction. [Half carry flag H] After operation, this is set when there is a carry from bit 3 of ALU or there is no borrow from bit 4 of ALU. This bit can not be set or cleared except CLRV instruction with Overflow flag (V). [Break flag B] This flag is set by software BRK instruction to distinguish BRK from TCALL instruction with the same vector address. [Direct page flag G] This flag assigns RAM page for direct addressing mode. In the direct addressing mode, addressing area is from zero page 00H to 0FFH when this flag is "0". If it is set to "1", addressing area is assigned by RPR register (address 0F3H). It is set by SETG inWhen content of RPR is above 2, malfunction will be occurred. [Overflow flag V] This flag is set to "1" when an overflow occurs as the result of an arithmetic operation involving signs. An overflow occurs when the result of an addition or subtraction exceeds +127(7FH) or 128(80H). The CLRV instruction clears the overflow flag. There is no set instruction. When the BIT instruction is executed, bit 6 of memory is copied to this flag. [Negative flag N] This flag is set to match the sign bit (bit 7) status of the result of a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag. struction and cleared by CLRG. Bit1 of RPR X 0 0 1 1 Bit0 of RPR X 0 1 0 1
RAM Page 0 page 0 page 1 page Reserved Reserved
Instruction CLRG SETG SETG SETG SETG
APR., 2001 Ver 2.01
19
GMS81C7008/7016
At execution of a CALL/TCALL/PCALL
At acceptance of interrupt
At execution of RET instruction
At execution of RET instruction
01FF 01FE 01FD 01FC
PCH PCL
Push down
01FF 01FE 01FD 01FC
PCH PCL PSW
Push down
01FF 01FE 01FD 01FC
PCH PCL
Pop up
01FF 01FE 01FE 01FC
PCH PCL PSW
Pop up
SP before execution SP after execution
01FF 01FD
01FF 01FC
01FD 01FF
01FC 01FF
At execution of PUSH instruction PUSH A (X,Y,PSW) 01FF 01FE 01FD 01FC A Push down
At execution of POP instruction POP A (X,Y,PSW) 01FF 01FE 01FD 01FC 01FFH A Pop up 0100H
Stack depth
SP before execution SP after execution
01FF 01FE
01FE 01FF
Figure 8-4 Stack Operation
20
APR., 2001 Ver 2.01
GMS81C7008/7016
8.2 Program Memory
A 16-bit program counter is capable of addressing up to 64K bytes, but this device has 8K/16K bytes program memory space only physically implemented. Accessing a location above FFFFH will cause a wrap-around to 0000H. Figure 8-5, shows a map of Program Memory. After reset, the CPU begins execution from reset vector which is stored in address FFFEH and FFFFH as shown in Figure 8-6. As shown in Figure 8-5, each area is assigned a fixed location in Program Memory. Program Memory area contains the user program.
C000H
save program byte length. Table Call (TCALL) causes the CPU to jump to each TCALL address, where it commences the execution of the service routine. The Table Call service area spaces 2-byte for every TCALL: 0FFC0H for TCALL15, 0FFC2H for TCALL14, etc., as shown in Figure 8-7. Example: Usage of TCALL The interrupt causes the CPU to jump to specific location, where it commences the execution of the service routine. The External interrupt 0, for example, is assigned to location 0FFFAH. The interrupt service locations spaces 2-byte interval: 0FFF8H and 0FFF9H for External Interrupt 1, 0FFFAH and 0FFFBH for External Interrupt 0, etc. Any area from 0FF00H to 0FFFFH, if it is not going to be used, its service location is available as general purpose Program Memory.
E000H
16K ROM
Address
0FFE0H E2 E4 E6 E8 EA EC EE F0 F2 F4 F6 F8 FA FC FE
Vector Area Memory Timer/Counter 3 Timer/Counter 2 Watch Timer A/D Converter Serial Peripheral Interface External Interrupt 2 Timer/Counter 1 Timer/Counter 0 External Interrupt 1 External Interrupt 0 Watchdog Timer Basic Interval Timer Key Scan RESET
GMS81C7008 8K ROM
FEFFH FF00H PCALL area
FFC0H TCALL area FFDFH FFE0H FFFFH Interrupt Vector Area
GMS81C7016
Figure 8-5 Program Memory Map Page Call (PCALL) area contains subroutine program to reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called, it is more useful to
NOTE: "-" means reserved area.
Figure 8-6 Interrupt Vector Area
APR., 2001 Ver 2.01
21
GMS81C7008/7016
Address 0FF00H
PCALL Area Memory
Address 0FFC0H C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
Program Memory TCALL 15 TCALL 14 TCALL 13 TCALL 12 TCALL 11 TCALL 10 TCALL 9 TCALL 8 TCALL 7 TCALL 6 TCALL 5 TCALL 4 TCALL 3 TCALL 2 TCALL 1 TCALL 0 / BRK * NOTE: * means that the BRK software interrupt is using same address with TCALL0.
PCALL Area (256 Bytes)
0FFFFH
Figure 8-7 PCALL and TCALL Memory Area
PCALL rel
4F35 PCALL 35H
TCALL n
4A TCALL 4
4F 35 ~ ~
4A ~ ~ NEXT
01001010
1
Reverse
~ ~
0FF00H 0FF35H NEXT
~ ~
0D125H
PC: 11111111 11010110 FH FH DH 6H
0FF00H 0FFD6H 0FFD7H 25 D1
3
2
0FFFFH
0FFFFH
22
APR., 2001 Ver 2.01
GMS81C7008/7016
Example: The usage software example of Vector address for GMS81C7016. ORG DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW 0FFE0H TIMER3 TIMER2 WATCH_TIMER ADC SIO NOT_USED NOT_USED INT2 TIMER1 TIMER0 INT1 INT0 WD_TIMER BIT_TIMER KEYSCAN RESET ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Timer-3 Timer-2 Watch Timer ADC Serial Interface Int.2 Timer-1 Timer-0 Int.1 Int.0 Watchdog Timer Basic Interval Timer Key Scan Timer Reset
;
ORG ORG
0C000H 0E000H
; in case of 16K ROM Start address ; in case of 8K ROM Start address
;******************************************* ; MAIN PROGRAM * ;******************************************* ; RESET: LDM SCMR,#0 ;When main clock mode DI ;Disable All Interrupts LDM WDTR,#0 ;Disable Watch Dog Timer LDM RPR,#1 CLRG LDX #0 RAM_CLR: LDA #0 ;RAM Clear(!0000H ~ !00BFH) STA {X}+ CMPX #0C0H BNE RAM_CLR SETG LDX #0 RAM_CLR1: LDA #0 STA {X}+ CMPX #1BH ;DISPLAY RAM Clear(!0100H ~ !011AH) BNE RAM_CLR1 CLRG ; LDX #0FFH ;Stack Pointer Initialize TXSP ; LDM R0, #0 ;Normal Port 0 LDM R0DD,#82H ;Normal Port Direction LDM R0PU,#0 ;Normal Pull Up : : : LDM TDR0,#250 ;8us x 250 = 2000us LDM TM0,#0000_1111B ;Start Timer0, 8us at 4MHz LDM IRQH,#0 LDM IRQL,#0 LDM IENH,#0000_1110B ;Enable INT0, INT1, Timer0 LDM IENL,#0 LDM IEDS,#15H ;Select falling edge detect on INT pin LDM PMR,#3H ;Set external interrupt pin(INT0, INT1) EI ;Enable master interrupt
APR., 2001 Ver 2.01
23
GMS81C7008/7016
8.3 Data Memory
Figure 8-8 shows the internal Data Memory space available. Data Memory is divided into four groups, a user RAM, control registers, Stack, and LCD memory.
0000H
Control Registers
The control registers are used by the CPU and Peripheral function blocks for controlling the desired operation of the device. Therefore these registers contain control and status bits for the interrupt system, the timer/ counters, analog to digital converters and I/O ports. The control registers are in address range of 0C0H to 0FFH. Note that unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. More detailed informations of each register are explained in each peripheral section.
User Memory (192 Bytes)
PAGE0
00BFH 00C0H
Control Registers 00FFH 0100H LCD display RAM (27 Nibbles) 011AH 011BH User Memory or Stack Area (229 Bytes) PAGE1
Note: Write only registers can not be accessed by bit manipulation instruction (SET1, CLR1). Do not use read-modify-write instruction. Use byte manipulation instruction, for example "LDM".
Example; To write at CKCTLR
01FFH
LDM
CKCTLR,#09H ;Divide ratio(/16)
Figure 8-8 Data Memory Map
User Memory
The both GMS81C7008/16 has 448 x 8 bits for the user memory (RAM). There are two page internal RAM. Page is selected by G-flag and RAM page selection register RPR. When G-flag is cleared to "0", always page 0 is selected regardless of RPR value. If G-flag is set to "1", page will be selected according to RPR value.
Stack Area
The stack provides the area where the return address is saved before a jump is performed during the processing routine at the execution of a subroutine call instruction or the acceptance of an interrupt. When returning from the processing routine, executing the subroutine return instruction [RET] restores the contents of the program counter from the stack; executing the interrupt return instruction [RETI] restores the contents of the program counter and flags. The save/restore locations in the stack are determined by the stack pointed (SP). The SP is automatically decreased after the saving, and increased before the restoring. This means the value of the SP indicates the stack location number for the next save. Refer to Figure 8-4 on page 20.
Page 0 G=0 RPR=1, G=1 Page 1 Page 0: 00~FFH Page 1: 100~1FFH
Figure 8-9 RAM page configuration
24
APR., 2001 Ver 2.01
GMS81C7008/7016
8.4 List of Control Registers
Address 00C0 00C1 00C2 00C3 00C4 00C5 00C6 00C8 00C9 00CA 00CB 00CC 00CD 00CE 00D0 00D1 00D2 00D3 00D4 00D5 00D6 00D7 00D8 00D9 00DA 00DB 00DC 00DD 00DE 00DF 00E0 Register Name R0 port data register R1 port data register R2 port data register R3 port data register R4 port data register R5 port data register R6 port data register R0 port I/O direction register R1 port I/O direction register R2 port I/O direction register R3 port I/O direction register R4 port I/O direction register R5 port I/O direction register R6 port I/O direction register R0 port pull-up register R1 port pull-up register R2 port pull-up register R3 port pull-up register R0 port open drain control register R1 port open drain control register R2 port open drain control register R3 port open drain control register Ext. interrupt edge selection register Port mode register Interrupt enable lower byte register Interrupt enable upper byte register Interrupt request flag lower byte register Interrupt request flag upper byte register Sleep mode register Watch dog timer register Timer0 mode register Timer0 counter register 00E1 Timer0 data register Timer0 input capture register 00E2 Timer1 mode register Symbol R0 R1 R2 R3 R4 R5 R6 R0DD R1DD R2DD R3DD R4DD R5DD R6DD R0PU R1PU R2PU R3PU R0CR R1CR R2CR R3CR IEDS PMR IENL IENH IRQL IRQH SMR WDTR TM0 T0 TDR0 CDR0 TM1 Table 8-1 Control Registers R/W R/W R/W R/W R/W R/W R/W R/W W W W W W W W W W W W W W W W R/W R/W R/W R/W R/W R/W W R/W R/W R W R R/W Initial Value
76543210
Page page 33 page 33 page 33 page 33 page 34 page 34 page 35 page 35 page 36 page 36 page 35 page 36 page 36 page 36 page 33 page 33 page 33 page 33 page 33 page 33 page 33 page 33 page 69
00000000 - - - - - -00 00000000 - 0000000 00000000 00000000 00000000 00000000 - - - - - -00 00000000 - 0000000 00000000 00000000 00000000 00000000 - - - - - -00 00000000 - 0000000 00000000 - - - - - -00 00000000 - 0000000 - - 000000
0 0 0 0 0 0 0 0 page 62, page 69 0 - - 00000 - 0000000 0 - - 00000 - 0000000 -------0 - - 010010 - - 000000 00000000 11111111 00000000 00000000 page 65 page 65 page 64 page 64 page 81 page 79 page 45 page 45 page 45 page 45 page 45
APR., 2001 Ver 2.01
25
GMS81C7008/7016
Address
Register Name Timer1 data register PWM0 pulse period register Timer1 counter register
Symbol TDR1 T1PPR T1 CDR1 T1PDR PWM0HR TM2 T2 TDR2 CDR2 TM3 TDR3 T3PPR T3 CDR3 T3PDR PWM1HR ADCM ADR WTMR KSMR LCR LPMR RPR BITR CKCTLR SCMR LVDR BUR SIOM SIOR Table 8-1 Control Registers
R/W W W R R R/W W R/W R W R R/W W W R R R/W W R/W R R/W R/W R/W R/W R/W R W R/W R/W W R/W R/W
Initial Value
76543210
Page page 45 page 54 page 45 page 45 page 54 page 54 page 46 page 46 page 46 page 46 page 46 page 46 page 54 page 46 page 46 page 46 page 54 page 58 page 58 page 79 page 69 page 71 page 71
00E3
11111111 11111111 00000000 00000000 00000000 - - - - 0000 - - 000000 00000000 11111111 00000000 00000000 11111111 11111111 00000000 00000000 00000000 - - - - 0000 - 0000001 Undefined - 0 - - 0000 - - - - - -00 00000000 - - 000000
00E4
Timer1 input capture register Timer1 pulse duty register
00E5 00E6
PWM0 high register Timer2 mode register Timer2 counter register
00E7
Timer2 data register Timer2 input capture register
00E8 00E9
Timer3 mode register Timer3 data register PWM1 pulse period register Timer3 counter register
00EA
Timer3 input capture register Timer3 pulse duty register
00EB 00EC 00ED 00EF 00F0 00F1 00F2 00F3 00F4 00F5 00FB 00FD 00FE 00FF
PWM1 high register A/D converter mode register A/D converter data register Watch timer mode register Key scan port mode register LCD control register LCD port mode register high RAM paging register Basic interval timer register Clock control register System clock mode register LVD register Buzzer data register Serial I/O mode register Serial I/O Data register
- - - - - - 0 0 page 24, page 71 00000000 - - - 00111 00000000 00000 - - 00000000 00000001 Undefined page 43 page 43 page 38 page 87 page 62 page 59 page 59
W
Registers are controlled by byte manipulation instruction such as LDM etc., do not use bit manipulation instruction such as SET1, CLR1 etc. If bit manipulation instruction is used on these registers, content of other seven bits are may varied to unwanted value. Registers are controlled by both bit and byte manipulation instruction.
R/W
- : this bit location is reserved.
26
APR., 2001 Ver 2.01
GMS81C7008/7016
Three registers are mapped on same address. Address E1H E3H E4H E7H E9H EAH Timer/Counter mode T0 [R], TDR0 [W] TDR1 [W] T1 [R] T2 [R], TDR2 [W] TDR3 [W] T3 [R] Capture mode CDR0 [R], TDR0 [W] TDR1 [W] CDR1 [R] CDR2 [R], TDR2 [W] TDR3 [W] CDR3 [R] PWM mode T1PPR [W] T1PDR [R/W] T3PPR [W] T3PDR [R/W]
Two registers are mapped on same address. Address F4H Basic Interval Timer BITR [R], CKCTLR [W]
APR., 2001 Ver 2.01
27
GMS81C7008/7016
8.5 Addressing Mode
The GMS800 series MCU uses six addressing modes; E45535 LDM 35H,#55H
* Register addressing * Immediate addressing * Direct page addressing * Absolute addressing * Indexed addressing * Register-indirect addressing
0F100H 0F101H 0F102H 0135H data data 55H
~ ~
E4 55 35
~ ~
(1) Register Addressing
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing #imm
In this mode, second byte (operand) is accessed as a data immediately. Example: 0435 ADC #35H
MEMORY
(3) Direct Page Addressing dp
In this mode, a address is specified within direct page. Example; G=0 C535 LDA 35H ;A RAM[35H]
35H 04 35
data
~ ~
A+35H+C A
~ ~
0E550H 0E551H C5 35
data A
When G-flag is 1, then RAM address is defined by 16-bit address which is composed of 8-bit RAM paging register (RPR) and 8-bit immediate data. Example: G=1, RPR=01
28
APR., 2001 Ver 2.01
GMS81C7008/7016
(4) Absolute Addressing !abs
Absolute addressing sets corresponding memory data to Data, i.e. second byte (Operand I) of command becomes lower level address and third byte (Operand II) becomes upper level address. With 3 bytes command, it is possible to access to whole memory area. ADC, AND, CMP, CMPX, CMPY, EOR, LDA, LDX, LDY, OR, SBC, STA, STX, STY Example; 0735F0 ADC !0F035H ;A ROM[0F035H]
ADC, AND, CMP, EOR, LDA, OR, SBC, STA, XMA Example; X=15H, G=1 D4 LDA {X} ;ACCRAM[X]
115H
data
~ ~
data A
~ ~
0E550H D4
0F035H
data
~ ~
~ ~
0F100H 0F101H 0F102H 07 35 F0
A+data+C A
X indexed direct page, auto increment {X}+
In this mode, a address is specified within direct page by the X register and the content of X is increased by 1. LDA, STA Example; G=0, X=35H
address: 0F035
The operation within data memory (RAM) ASL, BIT, DEC, INC, LSR, ROL, ROR Example; Addressing accesses the address 0135H regardless of G-flag. 983501 INC !0135H ;A ROM[135H]
DB
LDA
{X}+
35H
data
~ ~
data A
~ ~
DB 135H data
36H X
~ ~
~ ~
0F100H 0F101H 0F102H 98 35 01
data+1 data
address: 0135
X indexed direct page (8 bit offset) dp+X
This address value is the second byte (Operand) of command plus the data of -register. And it assigns the memory in Direct page. ADC, AND, CMP, EOR, LDA, LDY, OR, SBC, STA STY, XMA, ASL, DEC, INC, LSR, ROL, ROR
(5) Indexed Addressing X indexed direct page (no offset) {X}
In this mode, a address is specified by the X register.
Example; G=0, X=0F5H
APR., 2001 Ver 2.01
29
GMS81C7008/7016
C645
LDA
45H+X
Example; G=0 3F35 JMP [35H]
3AH
data
35H
0A E3
~ ~
0E550H 0E551H C6 45
36H
~ ~

data A 0E30AH
~ ~
NEXT
~ ~

jump to address 0E30AH
45H+0F5H=13AH
~ ~
0FA00H 3F 35
~ ~
Y indexed direct page (8 bit offset) dp+Y
This address value is the second byte (Operand) of command plus the data of Y-register, which assigns Memory in Direct page. This is same with above (2). Use Y register instead of X.
X indexed indirect [dp+X]
Processes memory data as Data, assigned by 16-bit pair memory which is determined by pair data [dp+X+1][dp+X] Operand plus X-register data in Direct page. ADC, AND, CMP, EOR, LDA, OR, SBC, STA Example; G=0, X=10H 1625 ADC [25H+X]
Y indexed absolute !abs+Y
Sets the value of 16-bit absolute address plus Y-register data as Memory.This addressing mode can specify memory in whole area. Example; Y=55H D500FA LDA !0FA00H+Y
35H 36H 0F100H 0F101H 0F102H
05 E0
D5 00 FA
~ ~
~ 0E005H ~
data
0FA00H+55H=0FA55H
0E005H
~ ~
25 + X(10) = 35H
~ ~ ~ ~
0FA55H data
~ ~
0FA00H data A 16 25
A + data + C A Y indexed indirect [dp]+Y
Processes memory data as Data, assigned by the data [dp+1][dp] of 16-bit pair memory paired by Operand in Direct pageplus Yregister data. ADC, AND, CMP, EOR, LDA, OR, SBC, STA Example; G=0, Y=10H
(6) Indirect Addressing Direct page indirect [dp]
Assigns data address to use for accomplishing command which sets memory data (or pair memory) by Operand. Also index can be used with Index register X,Y. JMP, CALL
30
APR., 2001 Ver 2.01
GMS81C7008/7016
1725
ADC
[25H]+Y
Example; G=0 1F25E0 JMP [!0E025H]
25H 26H
05 E0 PROGRAM MEMORY
~ ~
0E015H data
~ ~

0E005H + Y(10) = 0E015H 0E025H 0E026H 25 E7
~ ~
0FA00H 17 25
~ ~
~ ~
~ ~
NEXT
jump to address 0E30AH
A + data + C A
0E725H
~ ~
0FA00H 1F 25 E0
~ ~
Absolute indirect [!abs]
The program jumps to address specified by 16-bit absolute address. JMP
APR., 2001 Ver 2.01
31
GMS81C7008/7016
9. I/O PORTS
The GMS81C7008/16 has seven ports (R0, R1, R2, R3, R4, R5 and R6), and LCD segment port SEG0~SEG23, and LCD common p ort COM0~COM3, which are multiplexed with SEG24~SEG26. These ports pins may be multiplexed with an alternate function for the peripheral features on the device. In general, in a initial reset state, R0,R1,R2, R3 ports are used as a general purpose input port and R4, R5, R6 and R7 ports are used as LCD segment drive output port.
9.1 Registers for Port
Port Data Registers
The Port Data Registers in I/O buffer in each seven ports (R0,R1,R2,R3,R4,R5,R6) are represented as a Type D flip-flop, which will clock in a value from the internal bus in response to a "write to data register" signal from the CPU. The Q output of the flip-flop is placed on the internal bus in response to a "read data register" signal from the CPU. The level of the port pin itself is placed on the internal bus in response to "read data register" signal from the CPU. Some instructions that read a port activating the "read register" signal, and others activating the "read pin" signal When a port is used as input, input logic is firmly either low or high, therefore external pull-down or pull-up resisters are required practically. The GMS81C7008/16 has internal pull-up, it can be logic high by pull-up that can be able to configure either connect or disconnect individually by pull-up control registers R0PU, R1PU, R2PU and R3PU. When ports are configured as inputs and pull-up resistor is selected by software, they are pulled to high.
Port Direction Registers
All pins have data direction registers which can define these ports as output or input. A "1" in the port direction register configure the corresponding port pin as output. Conversely, write "0" to the corresponding bit to specify it as input pin. For example, to use the even numbered bit of R0 as output ports and the odd numbered bits as input ports, write "55H" to address 0C8H (R0 port direction register) during initial setting as shown in Figure 9-1.
VDD
VDD
PULL-UP RESISTOR Typ. 160k
PORT PIN
GND
Pull-up control bit 0: Disconnect 1: Connect
WRITE "55H" TO PORT R0 DIRECTION REGISTER 0C0H 0C1H R0 DATA R1 DATA 01010101 76543210 BIT
Figure 9-2 Pull-up Port Structure
Open drain port Registers
The R0, R1, R2 and R3 ports have open drain port resistors R0CR~R3CR. Figure 9-3 shows a open drain port configuration by control register. It is selected as either push-pull port or open-drain port by R0CR, R1CR, R2CR and R3CR.
~ ~
0C8H 0C9H R0 DIRECTION R1 DIRECTION
~ ~
IOIOIO I O PORT 76543210 I : INPUT PORT O : OUTPUT PORT
Figure 9-1 Example of port I/O assignment
PORT PIN
All the port direction registers in the MCU have 0 written to them by reset function. On the other hand, its initial status is input.
GND
Open drain port selection bit 0: Push-pull 1: Open drain
Pull-up Control Registers
The R0, R1, R2 and R3 ports have internal pull-up resistors. Figure 9-2 shows a functional diagram of a typical pull-up port. It is connected or disconnected by Pull-up Control register (PURn). The value of that resistor is typically 180k. Figure 9-3 Open-drain Port Structure
32
APR., 2001 Ver 2.01
GMS81C7008/7016
9.2 I/O Ports Configuration
R0 and R0DD register: R0 is an 8-bit CMOS bidirectional I/O port (address 0C0H). Each I/O pin can independently used as an input or an output through the R0DD register (address 0C8H). Each port also can be set individually as pull-up port through the R0PU (address 0D0H), and as open drain register through the R0CR (address 0D4H). In addition, port R0 is multiplexed with various special features. The control register through the PMR (address 0D9H) and the SIOM (address 0FEH) control the selection of alternate function. After reset, this value is "0", port may be used as normal I/O port. To use alternate function such as external interrupt, event counter input, serial interface data input, serial interface data output or serial interface clock, write "1" in the corresponding bit of PMR (address 0D9H) and SIOM (address 0FEH). Port pin R00 R01 R02 R03 R04 R05 R06 R07 Alternate function INT0 (External interrupt 0) INT1 (External interrupt 1) INT2 (External interrupt 2) EC0 (Event counter input 0) EC2 (Event counter input 2) SCK (Serial clock) SO (Serial data output) SI (Serial data input)
ADDRESS: 0D9H RESET VALUE: 00H 4 3 0: R04 1: EC2 0: R30 1: BUZ 0: R31 1: PWM0/T1O 0: R32 1: PWM1/T3O 2 1 0 0: R00 1: INT0 0: R01 1: INT1 0: R02 1: INT2 0: R03 1: EC0
Port Mode Register PMR
7 6 5
Edge Detection Register IEDS
5 4 3 2
ADDRESS: 0D8H RESET VALUE: 00H 1 0 INT0
INT2
INT1
External Interrupt Edge Select 00: Reserved 01: Falling (1-to-0 transition) 10: Rising (0-to-1 transition) 11: Both (Rising & Falling)
Regardless of the direction register R0DD, the control registers of PMR and SIOM are selected to use as alternate functions, port pin can be used as a corresponding alternate features . R0 Data Register R0
ADDRESS: 0C0H RESET VALUE: 00H
R1 and R1DD register: R1 is an 2-bit CMOS bidirectional I/O port (address 0C1H). Each I/O pin can independently used as an input or an output through the R1DD register (address 0C9H). Each port also can be set individually as pull-up port through the R1PU (address 0D1H), and as open drain register through the R1CR (address 0D5H). R1 Data Register R1
ADDRESS: 0C1H RESET VALUE: 00H R01 R00
R07 R06 R05 R04 R03 R02 R01 R00
Input / Output data Input / Output data
R0 Direction Register R0DD
ADDRESS: 0C8H RESET VALUE: 00H
R1 Direction Register R1DD
-
ADDRESS: 0C9H RESET VALUE: 00H -
Port Direction 0: Input 1: Output
Port Direction 0: Input 1: Output
APR., 2001 Ver 2.01
33
GMS81C7008/7016
R1 Pull-up Register R1PU
-
ADDRESS: 0D1H RESET VALUE: 00H -
R2 Data Register R2
ADDRESS: 0C2H RESET VALUE: 00H
R07 R06 R05 R04 R03 R02 R01 R00
Port Pull-up 0: Pull-up resistor Off 1: Pull-up resistor On
Input / Output data
R1 Open drain control Register R1CR
-
ADDRESS: 0D5H RESET VALUE: 00H
R2 Direction Register R2DD
ADDRESS: 0CAH RESET VALUE: 00H
Port Open drain 0: Push Pull 1: Open drain
Port Direction 0: Input 1: Output
R2 and R2DD register: R2 is an 8-bit CMOS bidirectional I/O port (address 0C2H). Each I/O pin can independently used as an input or an output through the R2DD register (address 0CAH). Each port also can be set individually as pull-up port through the R2PU (address 0D2H), and as open drain register through the R2CR (address 0D6H). In addition, port R2 is multiplexed with analog input port.
R2 Pull-up Register R2PU
ADDRESS: 0D2H RESET VALUE: 00H
Port Pull-up 0: Pull-up resistor Off 1: Pull-up resistor On
R2 Open drain control Register Port pin R20 R21 R22 R23 R24 R25 R26 R27 Alternate function AN0 (Analog Input 0) AN1 (Analog Input 1) AN2 (Analog Input 2) AN3 (Analog Input 3) AN4 (Analog Input 4) AN5 (Analog Input 5) AN6 (Analog Input 6) AN7 (Analog Input 7) R2CR
ADDRESS: 0D6H RESET VALUE: 00H
Port Open drain 0: Push Pull 1: Open drain
34
APR., 2001 Ver 2.01
GMS81C7008/7016
R3 and R3DD register: R3 is an 8-bit CMOS bidirectional I/O port (address 0C3H). Each I/O pin can independently used as an input or an output through the R3DD register (address 0CBH). Each port also can be set individually as pull-up port through the R3PU (address 0D3H), and as open drain register through the R3CR (address 0D7H). In addition, port R3 is multiplexed with various special features. Port pin R30 R31 R32 R33 R34 R35 R36 Alternate function BUZ (Buzzer driving output) PWM0 / T1O (PWM 0 output / Timer 1 output) PWM1 /T3O (PWM 1 output / Timer 3 output) WDTO (Watchdog timer output) SXOUT (Sub clock output) SXIN (Sub clock input)
Port Selection Register PMR
7 6 5 4 3
ADDRESS: 0D9H RESET VALUE: 00H 2 1 0 0: R00 1: INT0 0: R01 1: INT1 0: R02 1: INT2 0: R03 1: EC0
0: R04 1: EC2 0: R30 1: BUZ 0: R31 1: PWM0/T1O 0: R32 1: PWM1/T3O
Watch Dog Timer Register WDTR
-
ADDRESS: 0DFH RESET VALUE: --01_0010B
WDOE WDEN WDCK1 WDCK0 WDOM WDCLR
0: R34 1: WDTO
R3 Data Register R3
-
ADDRESS: 0C3H RESET VALUE: 00H
LCD Control Register LCR
R06 R05 R04 R03 R02 R01 R00
ADDRESS: 0F1H RESET VALUE: 00H
S U BM BTC LCDEN BRC DTY1 DTY0 LCK1 LCK0
Input / Output data
0: SXOUT, SXIN(Sub Clock Oscillation) 1: R35, R36(Sub Clock Disable)
R3 Direction Register R3DD
-
ADDRESS: 0CBH RESET VALUE: 00H
Port Direction 0: Input 1: Output
R3 Pull-up Register R3PU
-
ADDRESS: 0D3H RESET VALUE: 00H
Port Pull-up 0: Pull-up resistor Off 1: Pull-up resistor On
R3 Open drain control Register R3CR
-
ADDRESS: 0D7H RESET VALUE: 00H
Port Open drain 0: Push Pull 1: Open drain
APR., 2001 Ver 2.01
35
GMS81C7008/7016
R4 and R4DD register: R4 is an 8-bit CMOS bidirectional I/O port (address 0C4H). Each I/O pin can independently used as an input or an output through the R4DD register (address 0CCH). After Reset, R4 port is used as LCD segment o utput SEG0~SEG7. To use general I/O ports user should be written appropriate value into the LPMR (0F3H). LCD pin function SEG0 (LCD segment 0 signal output) SEG1 (LCD segment 1 signal output) SEG2 (LCD segment 2 signal output) SEG3 (LCD segment 3 signal output) SEG4 (LCD segment 4 signal output) SEG5 (LCD segment 5 signal output) SEG6 (LCD segment 6 signal output) SEG7 (LCD segment 7 signal output) Port pin R40 R41 R42 R43 R44 R45 R46 R47 R5 Direction Register R5DD
Port Direction 0: Input 1: Output ADDRESS: 0CDH RESET VALUE: 00H
R5 Data Register R5
ADDRESS: 0C5H RESET VALUE: 00H
R57 R56 R55 R54 R53 R52 R51 R50
Input / Output data
R6 and R6DD register: R6 is an 8-bit CMOS bidirectional I/O port (address 0C6H). Each I/O pin can independently used as an input or an output through the R6DD register (address 0CE H). R4 Data Register R4
ADDRESS: 0C4H RESET VALUE: 00H
R47 R46 R45 R44 R43 R42 R41 R40
After Re set, R6 port is used as LCD segm ent output SEG16~SEG23. To use general I/O ports user should be written appropriate value into the LPMR (0F3H). LCD pin function SEG16 (LCD segment 16 signal output) SEG17 (LCD segment 17 signal output) SEG18 (LCD segment 18 signal output) SEG19 (LCD segment 19 signal output) SEG20 (LCD segment 20 signal output) SEG21 (LCD segment 21 signal output) SEG22 (LCD segment 22 signal output) SEG23 (LCD segment 23 signal output) Port pin R60 R61 R62 R63 R64 R66 R66 R67
Input / Output data
R4 Direction Register R4DD
ADDRESS: 0CCH RESET VALUE: 00H
Port Direction 0: Input 1: Output
R5 and R5DD register: R5 is an 8-bit CMOS bidirectional I/O port (address 0C5H). Each I/O pin can independently used as an input or an output through the R4DD register (address 0CDH). After Reset, R5 port is used as LCD segment o utput SEG8~SEG15. To use general I/O ports user should be written appropriate value into the LPMR (0F3H). LCD pin function SEG8 (LCD segment 8 signal output) SEG9 (LCD segment 9 signal output) SEG10 (LCD segment 10 signal output) SEG11 (LCD segment 11 signal output) SEG12 (LCD segment 12 signal output) SEG13 (LCD segment 13 signal output) SEG14 (LCD segment 14 signal output) SEG15 (LCD segment 15 signal output) Port pin R50 R51 R52 R53 R54 R55 R56 R57 R6 Data Register R6
ADDRESS: 0C6H RESET VALUE: 00H
R67 R66 R65 R64 R63 R62 R61 R60
Input / Output data
R6 Direction Register R6DD
ADDRESS: 0CEH RESET VALUE: 00H
Port Direction 0: Input 1: Output
36
APR., 2001 Ver 2.01
GMS81C7008/7016
10. CLOCK GENERATOR
As shown in Figure 10-1, the clock generator produces the basic clock pulses which provide the system clock to be supplied to the CPU and the peripheral hardware. It contains two oscillators: a main-frequency clock oscillator and a sub-frequency clock oscillator. Power consumption can be reduced by switching them to the low power operation frequency clock can be easily obtained by attaching a resonator between the XIN and XOUT pin and the SXIN and SXOUT pin, respectively. The system clock can also be obtained from the external oscillator. The clock generator produces the system clocks forming clock pulse, which are supplied to the CPU and the peripheral hardware. The internal system clock can be selected by bit2, and bit3 of the System Clock Mode Register(SCMR). Instruction cycle time CPU clock /2 /8 / 16 / 64 XIN = 4MHz 0.5 us 2.0 us 4.0 us 16.0 us SXIN = 32.768kHz 61 us 244 us 488 us 1953 us
The register is shown in Figure 10-2. To the peripheral block, the clock among the not-divided original clocks, divided by 2, 4,..., up to 1024 can be provided. Peripheral clock is enabled or disabled by STOP instruction.
SYCC<1> SYCC<0>
STOP Mode
SLEEP Mode
SCS[1:0] select clock CLOCK PULSE GENERATOR
OSC Stop
/2 /8 /16 /64 MUX
XIN PIN SXIN PIN
OSC Stop LCR<7>
0 1
fEX
Internal system clock (CPU clock)
PRESCALER PS0 PS1 PS2 PS3 PS4 PS5 PS6 PS7 PS8 PS9 PS10
/1
/2
/4
/8
/16
/32
/64
/128
/256
/512 /1024
Peripheral clock
fEX(MHz)
4 Frequency period
PS0 4M 250n
PS1 2M 500n
PS2 1M 1u
PS3 500K 2u
PS4 250K 4u
PS5 125K 8u
PS6 62.5K 16u
PS7 31.25K 32u
PS8 15.63K 64u
PS9
PS10
7.183K 3.906K 128u 256u
Figure 10-1 Block Diagram of Clock Generator
APR., 2001 Ver 2.01
37
GMS81C7008/7016
The system clock is decided by bit1 (SYCC1) of the system clock mode register(SCMR). In selection Sub clock, to oscillate or stop the Main clock is decided by bit0 (SYCC0) of SCMR. On the ini-
tial reset, internal system clock is PS1 which is the fastest and other clock can be provided by bit2 and bit3 of SCMR.
SCMR
7 -
6 -
5 -
4 -
R/W R/W R/W R/W 3 2 1 0 BTCL SCS0 SYCC1 SYCC0 SCS1
ADDRESS: 0F5H INITIAL VALUE: 00H System (CPU) clock control 00: main clock on 01: main clock on 10: sub clock on (main clock on) 11: sub clock on (main clock off) System clock source select 00: XIN/2 or SXIN/2 01: XIN/8 or SXIN/8 10: XIN/16 or SXIN/16 11: XIN/64 or SXIN/64
Figure 10-2 SCMR: System Clock Control Registers
38
APR., 2001 Ver 2.01
GMS81C7008/7016
11. OPERATION MODE
The system clock controller starts or stops the main-frequency clock oscillator and switches between the sub frequency clock. The operating mode is generally divided into the main-clock mode and the sub-clock mode, which are controlled by System clock mode register (SCMR). Figure 11-1shows the operating mode transition diagram. System clock control is performed by the system clock mode register, SCMR. During reset, this register is initialized to "0" so that the main-clock operating mode is selected.
Sub-clock operating mode
This mode is low-frequency operating mode In this mode, the high-frequency clock oscillation is stops and low-frequency clock oscillation is active to operate the CPU and the peripheral hardware on the low-frequency clock, thereby reducing power consumption
SLEEP mode
In this mode, the CPU clock stops while peripherals and the oscillation source continue to operate normally.
Main-clock operating mode
This mode is fast-frequency operating mode. The CPU and the peripheral hardwares are operated on the highfrequency clock. At reset release, this mode is invoked.
STOP mode
In this mode, the system operations are all stopped, holding the internal states valid immediately before the stop at the low power consumption level.
Main - Oscillating Sub - Oscillating
Main - According to SCMR Sub - Oscillating
Instruction
Sub-clock Main-clock Mode Instruction Mode
ns tr u
Release
NOTE1:
ST
r to
RESET Key Scan Int. Watch Timer Int. Timer interrupt (EC0, EC2) External Int. SIO Int. Watchdog Timer Int. RESET All Int.
Reset
cti o
n
tr u In s
te 1
fe Re
OP I
no
o cti n
r to no
Re fe
te 2
RESET Operation
NOTE2:
t se Re
Main: Oscillating Sub: Oscillating
Re se
t
Main: Stopped Sub: Oscillating
STOP Mode
SLEEP Mode
Main: According to SCMR Sub: Oscillating
CPU and Peripherals are stops,
CPU stops, Peripherals are operate.
Figure 11-1 Operating Mode
APR., 2001 Ver 2.01
39
GMS81C7008/7016
11.1 Operation Mode Switching
In the Main-clock operation mode, only the high-frequency clock oscillator is used. In the Sub-clock operation mode, the high-frequency clock oscillation stops, enabling the low power voltage operation or the low power consumption operation. Instruction execution does not stop when the operation speed switching is performed. However, some peripheral hardware capabilities may be affected. For details, refer to the description of the relevant operation. The following describes the switching between the Main-clock and the Sub-clock operations. During reset, the system clock mode register is initialized at the Main-clock mode. It must be set to the Sub-clock operation for the low-power consumption mode. ;20ms software delay at fXIN=4MHz DELAY: DLP0: DLP1: LDY LDA NOP INC BCC INC CMPY BCC RET #0 #0 A DLP1 Y #20 DLP0
Switching from main clock operation to subclock operation
First, write "10B" into lower 2 bits of SCMR to switch the main system clock to the sub-frequency clock. Next, write "11B" to turn off main frequency oscillation.
Shifting from the Normal operation to the SLEEP mode
By setting bit 0 of SMR, the CPU clock stops and the SLEEP mode is invoked. The CPU stops while other peripherals are operate normally. The way of release from this mode is RESET and all available interrupts. For more detail, See "20.1 SLEEP Mode" on page 81
Example:
: : MOV MOV : :
SCMR,#0000_XX10B SCMR,#0000_XX11B
;Switch to sub mode ;Turn off main clock
Shifting from the Normal operation to the STOP mode
By executing STOP instruction, the main-frequency clock oscillation stops and the STOP mode is invoked. But sub-frequency clock oscillation is operated continuously. After the STOP operation is released by reset, the operation mode is changed to Main-clock mode. The methods of release are RESET, Key scan interrupt, Watch Timer interrupt, Timer/Event counter1 (EC0, EC2 pin), and External Interrupt. For more details, see "20.2 STOP Mode" on page 82.
Returning from sub clock operation to main clock operation
First, write "10B" into lower 2 bits of the SCMR to turn on the main-frequency oscillation, when the stabilization (warm-up) has been taken by the software delay routine. Sub clock operation mode can also be released by setting the RESET pin to low, which immediately performs the reset operation. After reset, the GMS81C7008/16 is placed in main frequency operation mode.
Example:
: : : MOV SCMR,#0000_XX10B CALL DELAY MOV SCMR,#0000_XX00B : : :
;Turn on main-clock ;Wait until stable ;Move to main mode
Note: In the STOP and Sub clock operating modes, the power consumed by the oscillator and the internal hardware is reduced. However, the power for the pin interface (depending on external circuitry and program) is not directly associated with the low-power consumption operation. This must be considered in system design as well as interface circuit design.
40
APR., 2001 Ver 2.01
GMS81C7008/7016
~ ~
Main freq. clock (XIN pin) Sub freq. clock (SXIN pin)
~ ~ ~ ~ ~ ~
Operation clock
Main-clock operation
Changed to the Sub-clock
SCMR XXXX XX10B
Turn off main clock
SCMR XXXX XX11B
(a) Main clock mode Sub clock mode
~ ~
Sub-clock operation
~ ~
Main freq. clock (XIN pin)
Stabilizing Time > 20ms
~ ~ ~ ~
Sub freq. clock (SXIN pin)
Operation clock
~ ~
Sub-clock operation Main-clock operation
Changed to the Transition SCMR XXXX XX10B
Changed to the Main-clock SCMR XXXX XX00B or 01B
(b) Sub clock Main clock
Figure 11-2 System Clock Switching Timing
APR., 2001 Ver 2.01
41
GMS81C7008/7016
12. BASIC INTERVAL TIMER
The GMS81C7008/16 has one 8-bit Basic Interval Timer that is free-run and can not stop. Block diagram is shown in Figure 12-1. In addition, the Basic Interval Timer generates the time base for watchdog timer counting. It also provides a Basic interval timer interrupt (BITIF). As the count overflow from FFH to 00H, this overflow causes the interrupt to be generated. The Basic Interval Timer is controlled by the clock control register (CKCTLR) shown in Figure 12-2. Source clock can be selected by lower 3 bits of CKCTLR. The registers BITR and CKCTLR are located at same address, and address 0F9H is read as a BITR, and written to CKCTLR.
/8
SCMR[1:0] Prescaler fXIN fSXIN
0X 1X
/16 /32 /64 /128 /256 /512 /1024
MUX
source clock
8-bit up-counter
overflow
BITIF Basic Interval Timer Interrupt
[0F9H] clear To Watchdog timer (WDTCK)
Select Input clock 3 BTS[2:0] [0F4H] Basic Interval Timer clock control register Internal bus line CKCTLR BTCL BITR Read
Figure 12-1 Block Diagram of Basic Interval Timer
Interrupt (overflow) Period (ms) BTS[2:0] 000 001 010 011 100 101 110 111 CPU Source clock /8 /16 /32 /64 /128 /256 /512 /1024 @ fXIN = 4MHz 0.512 1.024 2.048 4.096 8.192 16.384 32.768 65.536 @ fSXIN = 32.768kHz 62.5ms 125ms 250ms 500ms 1000ms 2000ms 4000ms 8000ms
Table 12-1 Basic Interval Timer Interrupt Time
42
APR., 2001 Ver 2.01
GMS81C7008/7016
CKCTLR
7 -
6 -
5 -
W W W W 3 2 1 0 BCK BTCL BTS2 BTS1 BTS0 BTCL
W 4
ADDRESS: 0F4H INITIAL VALUE: ---0 0111B
Caution:
Both register are in same address, when write, to be a CKCTLR, when read, to be a BITR.
Basic Interval Timer source clock select 000: fXIN / 8 or fSXIN / 8 001: fXIN / 16 or fSXIN / 16 010: fXIN / 32 or fSXIN / 32 011: fXIN / 64 or fSXIN / 64 100: fXIN / 128 or fSXIN / 128 101: fXIN / 256 or fSXIN / 256 110: fXIN / 512 or fSXIN / 512 111: fXIN / 1024 or fSXIN / 1024 Clear bit 0: Normal operation, free-run 1: Clear 8-bit counter (BITR) to "0" and count up again. This bit becomes to "0" automatically after one machine cycle. For the test purpose. This bit must be cleared to "0" for normal operation, otherwise BIT clock source is form sub-clock.
R 7
R 6
R 5
R 4
BITR
R 3 BTCL
R 2
R 1
R 0
ADDRESS: 0F4H INITIAL VALUE: Undefined
8-BIT FREE-RUN BINARY COUNTER
Figure 12-2 BITR: Basic Interval Timer Mode Register Example 1: Interrupt request flag is generated every 8.192ms at 4MHz. : LDM SET1 EI : CKCTLR,#0CH BITE
APR., 2001 Ver 2.01
43
GMS81C7008/7016
13. TIMER/EVENT COUNTER
The GMS81C7008/16 has four Timer/Event counters. Each module can generate an interrupt to indicate that an event has occurred (i.e. timer match). Timer 0 and Timer 1 are can be used either two 8-bit Timer/ Counter or one 16-bit Timer/Counter with combine them. Also Timer 2 and Timer 3 can be joined as a 16-bit Timer/Counter. In the "timer" function, the register is increased every internal clock input. Thus, one can think of it as counting internal clock input. The count rate is 1/2 to 1/2048 of the oscillator frequency. In the "counter" function, the register is incremented in response to a 0-to-1 (rising edge) transition at its corresponding external input pin, EC0 or EC2 pin. In addition the "capture" function, the register is incremented in response external or internal clock sources same with timer or counter function. When external clock edge input, the count register is captured into Capture data register correspondingly. It has five operating modes: "8-bit timer/counter", "16-bit timer/ counter", "8-bit capture", "16-bit capture", "PWM mode" which are selected by bit in Timer mode register TMn. In operation of Timer 2, Timer 3, their operations are same with Timer 0, Timer 1, respectively. When programming the software, you may refer to following example.
Example 1: Timer 0 = 8-bit timer mode, 8ms interval at 4MHz Timer 1 = 8-bit timer mode, 4ms interval at 4MHz Timer 2 = 16-bit event counter mode LDM LDM LDM LDM LDM LDM LDM LDM LDM SET1 SET1 EI : : Example 2: Timer0 = 16-bit timer mode, 0.5s at 4MHz Timer2 = 2ms 8-bit timer mode at 4MHz Timer3 = 250us 8-bit timer mode at 4MHz LDM LDM LDM LDM LDM LDM LDM LDM LDM SET1 SET1 SET1 EI : : SCMR,#0 ;Main clock mode TDR0,#23H TDR1,#0F4H TM0,#0FH ;FXIN/32, 8us TM1,#4CH TDR2,#249 TDR3,#124 TM2,#0FH TM3,#0DH T0E T2E T3E SCMR,#0 ;Main clock mode TDR0,#249 TM0,#0001_0011B TDR1,#124 TM1,#0000_1111B TDR2,#1FH TDR3,#4CH TM2,#0001_1111B TM3,#0100_1100B T0E T2E
Example 3: Timer0 = 8-bit timer mode, 2ms interval at 4MHz Timer1 = 8-bit capture mode, 2us sampling count. LDM LDM LDM LDM LDM LDM SET1 SET1 SET1 EI : : X: don't care. Example 4: Timer0 = 8-bit timer mode, 2ms interval at 4MHz Timer2 = 16-bit capture mode, 8us sampling count. LDM LDM LDM LDM LDM LDM LDM LDM TDR0,#249 TM0,#0FH IEDS,#XX11_XXXXB PMR4,#XXXX_X1XXB TDR2,#0FFH TDR3,#0FFH TM2,#XX10_1111B TM3,#X10X_11XXB TDR0,#249 TM0,#0FH ;250x8=2000us ;FXIN/32, 8us ;FALLING ;AS INT1 ;2us
IEDS,#XXXX_01XXB PMR,#XXXX_XX1XB TDR1,#0FFH TM1,#0001_1011B T0E T1E INT1E
;ENABLE TIMER 0 ;ENABLE TIMER 1 ;ENABLE EXT. INT1
;MAX ;MAX ;/32
;FXUN/32, 8us ;FXIN/8, 2us SET1 SET1 SET1 EI : : X: don't care. T0E T2E INT2E ;ENABLE TIMER 0 ;ENABLE TIMER 2 ;ENABLE EXT. INT2
44
APR., 2001 Ver 2.01
GMS81C7008/7016
Timer 0 mode register
7 6 -
R/W 5
R/W 4
R/W 3
R/W 2
R/W 1
R/W 0 T0S T ADDRESS: 0E0H INITIAL VALUE: 00H
TM0
-
CAP 0 T0C K2 B TCL T0C K0 T0CN T0CK1
Timer/Counter 0 start/stop control flag 0: stop count 1: clearing the T0 counter and start count again Timer/Counter 0 enable flag 0: Disable count 1: Enable count Basic Interval Timer source clock select or fSXIN / 2 000: fXIN / 2 or fSXIN / 4 001: fXIN / 4 or fSXIN / 8 010: fXIN / 8 or fSXIN / 32 011: fXIN / 32 100: fXIN / 128 or fSXIN / 128 101: fXIN / 512 or fSXIN / 512 110: fXIN / 2048 or fSXIN / 2048 111: EC0 (External event input 0) Capture mode enable 0: Timer mode 1: Capture mode
Timer 1 mode register TM1
R/W 7
R/W 6
R/W 5
R/W 4
R/W 3
R/W 2
R/W 1
R/W 0 T1S T
PO L0 16BIT0 PW M E0 CA P1 T1C K1 T1CK0 T1CN B TCL
ADDRESS: 0E2H INITIAL VALUE: 00H
PWM duty control 0: Active low 1: Active high Mode selection 0: 8-bit mode 1: 16-bit mode
Timer/Counter 1 start/stop control flag 0: stop count 1: clearing the T1 counter and start count again Timer/Counter 1 enable flag 0: Disable count 1: Enable count Timer/Counter 1 source clock select 00: fXIN or fSXIN 01: fXIN / 2 or fSXIN / 2 (depend on SCMR) 10: fXIN / 8 or fSXIN / 8 11: Timer 0 clock Capture mode enable 0: Timer mode 1: Capture mode PWM enable bit 0: Disable 1: Enable
W 7
W 6
W 5
W 4
W 3
W 2
W 1
W 0
TDR0~TDR3
ADDRESS: 0E1H, 0E3H, 0E7H, 0E9H INITIAL VALUE: 0FFH
Compare data registers
Figure 13-1 TM0, TM1, TDRn Registers
APR., 2001 Ver 2.01
45
GMS81C7008/7016
Timer 2 mode register
7 6 -
R/W 5
R/W 4
R/W 3
R/W 2
R/W 1
R/W 0 T2S T ADDRESS: 0E6H INITIAL VALUE: 00H
TM2
-
CAP 2 T2C K2 B TCL T2C K0 T2C N T2CK1
Timer/Counter 2 start/stop control flag 0: stop count 1: clearing the T0 counter and start count again Timer/Counter 2 enable flag 0: Disable count 1: Enable count Timer/Counter 2 source clock select or fSXIN / 2 000: fXIN / 2 or fSXIN / 4 001: fXIN / 4 or fSXIN / 8 010: fXIN / 8 or fSXIN / 32 011: fXIN / 32 100: fXIN / 128 or fSXIN / 128 101: fXIN / 512 or fSXIN / 512 110: fXIN / 2048 or fSXIN / 2048 111: EC2 (External event input 2) Capture mode enable 0: Timer mode 1: Capture mode
Timer 3 mode register TM3
R/W 7
R/W 6
R/W 5
R/W 4
R/W 3
R/W 2
R/W 1
R/W 0 T3S T ADDRESS: 0E8H INITIAL VALUE: 00H
PO L1 16B IT1 PW M E1 CA P3 T3C K1 T3C K0 T3CN B TCL
PWM1 duty control 0: Active low 1: Active high Mode selection 0: 8-bit mode 1: 16-bit mode
Timer/Counter 3 start/stop control flag 0: stop count 1: clearing the T3 counter and start count again Timer/Counter 3 enable flag 0: Disable count 1: Enable count Timer/Counter 3 source clock selection or fSXIN 00: fXIN 01: fXIN / 2 or fSXIN / 2 (depend on SCMR) 10: fXIN / 8 or fSXIN / 8 11: Timer 2 clock Capture mode enable 0: Timer mode 1: Capture mode PWM enable bit 0: Disable 1: Enable
T0~T3 CDR0~CDR3
R 7
R 6
R 5
R 4
R 3
R 2
R 1
R 0
ADDRESS: 0E1H, 0E4H, 0E7H, 0EAH INITIAL VALUE: 00H
Count registers
Figure 13-2 TM2, TM3 Registers
46
APR., 2001 Ver 2.01
GMS81C7008/7016
13.1 8-bit Timer / Counter Mode
The GMS81C7008/16 has four 8-bit Timer/Counters, Timer 0, Timer 1, Timer 2, Timer 3 which are shown in Figure 13-3, Figure 13-4. The "timer" or "counter" function is selected by control registers TMn. To use as an 8-bit timer/counter mode, CAP0, CAP1,
7 6 X
16BIT0 and PWME bits should be cleared to "0". These timers have each 8-bit count register and data register. The count register is increased by every internal or external clock input. The internal clock has a prescaler divide ratio option of 2~2048 selected by control bits of register TMn (n=0,1,2,3).
5
0
4
X
3
X
2
X
1
X
0
X
TM0
X
BTCL CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST
ADDRESS: 0E0H INITIAL VALUE: 00H
TM1
POL0 16BIT0 PWM E0 CAP1 T1CK1 T1CK0 T1CN T1ST BTCL
X 0 0 0 X X X X
ADDRESS: 0E2H INITIAL VALUE: 00H
T0CK[2:0] Edge Detector
X means don't care
EC0 PIN
SCMR[1:0] Prescaler fXIN fSXIN
0X 1X
111
/2048 /512 /128 /32 /8 /4 /2
110 101 100 011 010 001 000
0 1 T0CN [0E1H]
T0ST 0: Stop 1: Clear and start T0 (8-bit)
clear TIMER 0 INTERRUPT
T0IF Comparator TDR0 (8-bit) [0E1H]
MUX
TIMER 0
T1CK[1:0] T1ST
11 10 01 00
0: Stop 1: Clear and start 0 1 T1CN Comparator TDR1 (8-bit) [0E3H] T1 (8-bit) [0E4H] T1IF clear F/F
/8 /2 /1
PMR.6 [0D9H.6]
R31/T1O/PWM0 PIN
TIMER 1 INTERRUPT
MUX
TIMER 1
Figure 13-3 8-bit Timer/Counter 0, 1
APR., 2001 Ver 2.01
47
GMS81C7008/7016
Note: The contents of Timer data register TDRx should be initialized with 1H~FFH, not to 0H, because it is not to defined before reset.
In the Timer 0, timer register T0 increments from 00H until it matches with TDR0 and then reset to 00H. The match output of Timer 0 generates Timer 0 interrupt (latched in T0IF bit)
7 6 X
As TDRx and Tx register are in same address, when reading it as a Tx, written to TDRx. In counter function, the counter is increased every 0-to-1 (rising edge) transition of EC0 or EC2 pin. In order to use counter function, the bit 3 and bit 4 of the Port mode register PMR are set to "1" by software. The Timer 0 can be used as a counter by pin EC0 input. Similarly, Timer 2 can be used by pin EC2 input.
5
0
4
X
3
X
2
X
1
X
0
X
TM2
X
CAP2 T2CK2 T2CK1 T2CK0 T2CN T2ST BTCL
ADDRESS: 0E6H INITIAL VALUE: 00H
TM3
POL1 16BIT1 PWME1 CAP3 T3CK1 T3CK0 T3CN T3ST BTCL
X 0 0 0 X X X X
ADDRESS: 0E8H INITIAL VALUE: 00H
T2CK[2:0] Edge Detector
X means don't care
EC2 PIN
SCMR[1:0] Prescaler fXIN fSXIN
0X 1X
111
/2048 /512 /128 /32 /8 /4 /2
110 101 100 011 010 001 000
0 1 T2CN
T2ST 0: Stop 1: Clear and start T2 (8-bit) [0E7H] T2IF Comparator TDR2 (8-bit) [0E7H] TIMER 2 INTERRUPT
clear
MUX
TIMER 2
T3CK[1:0] T3ST
11 10 01 00
0: Stop 1: Clear and start 0 1 T3CN Comparator TDR3 (8-bit) [0E9H] T3 (8-bit) [0EAH] T3IF clear F/F
/8 /2 /1
PMR.7 [0D9H.7]
R32/T3O/PWM0 PIN
TIMER 3 INTERRUPT
MUX
TIMER 3
Figure 13-4 8-bit Timer/Counter 2, 3
48
APR., 2001 Ver 2.01
GMS81C7008/7016
8-bit Timer Mode
In the timer mode, the internal clock is used for counting up. Thus, you can think of it as counting internal clock input. The contents of TDRn (n=0,1,2,3) are compared with the contents of up-counter, Tn (n=0,1,2,3). If match is found, a timer 1 interrupt
Start count
(T1IF) is generated and the up-counter is cleared to 0. Counting up is resumed after the up-counter is cleared. As the value of TDRn can be re-written by software, time interval is set as you want
Source clock Up-counter TDR1 T1IF interrupt
0 1 2 3
~ ~ ~ ~ n-2 ~ ~ n-1 n 0 1 2 3 4 Counter Clear Match Detect ~ ~
n ~ ~
Figure 13-5 Timer Mode Timing Chart
Example: Make 1msinterrupt using by Timer0 at 4MHz LDM LDM SET1 EI
When
TM0,#0FH TDR0,#124 T0E
; ; ; ;
divide by 32 8us x (124+1)= 1ms Enable Timer 0 Interrupt Enable Master Interrupt
TM0 = 0000_1111B (8-bit Timer mode, Prescaler divide ratio /32) TDR0 = 124D = 7CH fXIN = 4 MHz 1 INTERRUPT PERIOD = x 32 x (124+1) = 1 ms 4 x 106 Hz TDR1 7D 7B 7A
~~
MATCH (TDR0 = T0)
7D 7C 8 s
Count Pulse Period
~~
up
-c o ~~
un
t
6 5 4 3 2 1
0
0 Interrupt period = 8 s x 125
TIME
Timer 1 (T1IF) Interrupt
Occur interrupt
Occur interrupt
Occur interrupt
Figure 13-6 Timer Count Example
APR., 2001 Ver 2.01
49
GMS81C7008/7016
8-bit Event Counter Mode
In this mode, counting up is started by an external trigger. This trigger means rising edge of the EC0 or EC2 pin input. Source clock is used as an internal clock selected with timer mode register TM0, TM1, TM2 or TM3. The contents of timer data register TDRn (n = 0,1,2,3,........,FF) are compared with the contents of the up-counter Tn. If a match is found, an timer interrupt request flag TnIF is generated, and the counter is cleared to "0". The counter is restart and count up continuously by every rising edge of the ECn pin input. The maximum frequency applied to the ECn pin is fXIN/2 [Hz]. In order to use event counter function, the bit 3, 4 of the Port Mode Register PMR (address 0D9H) is required to be set to "1".
Start count ECn pin input ~ ~ ~ ~
After reset, the value of timer data register TDRn is undefined, it should be initialized to between 1H~FFHnot to "0". The interval period of Timer is calculated as below equation.
1 Period (sec) = --------- x 2 x Divide Ratio x TDRn f XIN
Up-counter TDR1 T1IF interrupt
0 n
1
2
n-1
n
0
1
2
Figure 13-7 Event Counter Mode Timing Chart
~ ~ ~ ~ ~ ~ ~ ~
TDR1 disable enable
clear & start stop
up -
co u
nt
~~
~ ~
TIME
Timer 1 (T1IF) Interrupt Occur interrupt T1ST Start & Stop T1ST = 0 T1CN Control count T1CN = 0 T1CN = 1 Occur interrupt
T1ST = 1
Figure 13-8 Count Operation of Timer / Event counter
50
APR., 2001 Ver 2.01
GMS81C7008/7016
13.2 16-bit Timer / Counter Mode
The Timer register is being run with all 16 bits. A 16-bit timer/ counter register T0, T1 are incremented from 0000H until it matches TDR0, TDR1 and then resets to 0000H. The match output generates Timer 0 interrupt. The clock source of the Timer 0 is selected either internal or external clock by bit T0SL1, T0SL0.
7 TM0 X
Even if the Timer 0 (including the Timer 1) is used as a 16-bit timer, the Timer 2 and Timer 3 can still be used as either two 8bit timer or one 16-bit timer by setting the TM2. Reversely, even if the Timer 2 (including the Timer 3) is used as a 16-bit timer, the Timer 0 and Timer 1 can still be used as 8-bit timer independently.
2 1 0
6 X
5
4
3
BTCL CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST
0 X X X X X
ADDRESS: 0E0H INITIAL VALUE: 00H ADDRESS: 0E2H INITIAL VALUE: 00H
TM1
BTCL POL0 16BIT0 PWME0 CAP1 T1CK1 T1CK0 T1CN T1ST
X 1 0 0 1 1 X X
X means don't care T0CK[2:0] Edge Detector
EC0 PIN
SCMR[1:0] Prescaler fXIN fSXIN
0X 1X
111
T0ST 0: Stop 1: Clear and start 0 1 T1 (16-bit) T0CN Comparator TDR1 Higher byte TDR0 Lower byte PMR.6 [0D9H.6] F/F T0IF TIMER 0 INTERRUPT (Not Timer 1 interrupt) T0 clear
/2048 /512 /128 /32 /8 /4 /2
110 101 100 011 010 001 000
R31/T1O/PWM0 PIN
MUX TIMER 0 + TIMER 1 TIMER 0 (16-bit)
COMPARE DATA
7 TM2 X
6 X
5
4
3
2
1
0
CAP2 T2CK2 T2CK1 T2CK0 T2CN T2ST BTCL
0 X X X X X
ADDRESS: 0E6H INITIAL VALUE: 00H ADDRESS: 0E8H INITIAL VALUE: 00H
TM3
POL1 16BIT1 PWME1 CAP3 T3CK1 T3CK0 T3CN T3ST BTCL
X 1 0 0 1 1 X X
X means don't care T2CK[2:0] Edge Detector
EC2 PIN
SCMR[1:0] Prescaler fXIN fSXIN
1X 1X
111
T2ST 0: Stop 1: Clear and start 0 1 T3 (16-bit) T2CN Comparator TDR3 Higher byte TDR2 Lower byte PMR.7 [0D9H.7] F/F T2IF TIMER 2 INTERRUPT (Not Timer 3 interrupt) T2 clear
/2048 /512 /128 /32 /8 /4 /2
110 101 100 011 010 001 000
R32/T3O/PWM1 PIN
MUX TIMER 0 + TIMER 1 TIMER 0 (16-bit)
COMPARE DATA
Figure 13-9 16-bit Timer/Counter
APR., 2001 Ver 2.01
51
GMS81C7008/7016
13.3 8-bit Capture Mode
The capture mode can be used to measure the pulse width between two edges. The Timer 0 capture mode is set by bit CAP0 of Timer Mode Register TM0, and the Timer 1 capture mode is set by CAP1 of Timer Mode Register TM1 as shown in Figure 13-10. Timer 2 and Timer 3 have same architecture with Timer 0 and Timer 1. The Timer/Counter register is incremented in response internal or external input. This counting function is same with normal timer mode, and Timer interrupt is generate when timer register T0 (T1, T2, T3) increase and match TDR0 (TDR1, TDR2, TDR3).
7 TM0 X
Timer/Counter still does the above, but with the added feature that a edge transition at external input INTn pin causes the current .
f xin f timer = ------------------------------------------------------------------------------2 x prescaler value x ( TDR + 1 )
6 X
5
4
3
2
1
0
CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST BTCL
1 X X X X X
ADDRESS: 0E0H INITIAL VALUE: 00H ADDRESS: 0E2H INITIAL VALUE: 00H
TM1
BTCL POL0 16BIT0 PWME0 CAP1 T1CK1 T1CK0 T1CN T1ST
X 0 0 1 X X X X
IEDS[1:0]
01
INT0 PIN
10 11
INT0IF
INT0 INTERRUPT
T0CK[2:0] Edge Detector
CDR0 CDR0 (8-bit) capture T0ST 0: Stop 1: Clear and start clear TIMER 0 INTERRUPT
EC0 PIN
SCMR[1:0] fXIN fSXIN
0X fEX 1X /2048 /512 /128 /32 /8 /4 /2 /1
111 110 101 100 011 010 001 000
clear T0 (8-bit) CDR0 (8-bit)
Prescaler
T0CN TDR0 (8-bit) CDR0 (8-bit)
Comparator
T0IF
MUX
COMPARE DATA
01
INT1 PIN
10 11
INT1IF
INT1 INTERRUPT
IEDS[3:2]
CDR1 CDR0 (8-bit) T1CK[1:0]
11 10 01 00
capture clear T1 (8-bit) CDR0 (8-bit) T1CN TDR1 (8-bit) CDR0 (8-bit) COMPARE DATA
T1ST 0: Stop 1: Clear and start clear TIMER 1 INTERRUPT
/8 /2 /1
MUX
Comparator
T1IF
F/F PMR.6 [0D9H.6]
R31/T1O/PWM0 PIN
Figure 13-10 8-bit Capture Mode (Timer0/Timer1 case)
52
APR., 2001 Ver 2.01
GMS81C7008/7016
value in the Timer counter register (T0,T1), to be captured and stored into registers CDRn (CDR0, CDR1), respectively. After capture, the Timer counter register is cleared and restarts by hardware. At this time, reading the address E1H as a CDR0, not T0. T0, TDR0, CDR0 are located at same address. The other CDR1~CDR3 are same. Refer to Timer registers of page 27. It has three transition modes: "falling edge", "rising edge", "both edge" which are selected by interrupt edge selection register IEDS. Refer to "17.4 External Interrupt" on page 68. In addition, the transition at INTn pin generate an interrupt.
7 6 X
Note: The CDRn and Tn are in same address.In the capture mode, reading operation is read as CDRn, not Tn because addressing path is opened to the CDRn.
5
1
4
X
3
X
2
X
1
X
0
X
TM0
X
BTCL CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST
ADDRESS: 0E0H INITIAL VALUE: 00H ADDRESS: 0E2H INITIAL VALUE: 00H
TM1
POL0 16BIT0 PWME0 CAP1 T1CK1 T1CK0 T1CN T1ST BTCL
X 1 0 1 1 1 X X
X means don't care IEDS[1:0]
01
INT0 PIN
10 11 MSB 16 BITS LSB
INT0IF
INT0 INTERRUPT
T0CK[2:0]
Edge Detector
CDR1
capture
CDR0 T0ST
0: Stop 1: Clear and start
EC0 PIN
SCMR[1:0] fXIN fSXIN
0X 1X /2048 /512 /128 /32 /8 /4 /2
111 110 101 100 011 010 001 000
clear clear
T1
T0 T0IF TIMER 0 INTERRUPT
fEX
Prescaler
T0CN
Comparator
TDR1
TDR0
F/F PMR.6 [0D9H.6]
MUX
COMPARE DATA
R31/T1O/PWM0 PIN
Figure 13-11 16-bit Capture Mode
13.4 16-bit Capture Mode
16-bit capture mode is the same as 8-bit capture, except that the Timer register is being run will 16 bits. Configuration is shown in Figure 13-11.
13.5 Timer output port mode
The GMS81C7008/16 has a function of Timer compare output. To pulse out, the timer match can goes out to port pin (T1O, T3O) as shown in Figure 13-3, Figure 13-4 and Figure 13-9. Thus pulse out is generated by the timer match. These operation is implemented to pin T1O, T3O. This pin output the signal having 50% duty square wave and output frequency is same as below equation. To use this function, the bit 6 and bit 7 of Port Mode Register (PMR) are set or clear properly. In addition, 16-bit Timer output mode is available, also
APR., 2001 Ver 2.01
53
GMS81C7008/7016
13.6 PWM Mode
The GMS81C70xx and GMS81C71xx have two high speed PWM (Pulse Width Modulation) functions which shared with
7 TM1 6 5 4 3 2
Timer 1 and Timer 3.
1
0 ADDRESS: 0E2H INITIAL VALUE: 00H ADDRESS: 0E5H INITIAL VALUE: 00H
BTCL POL0 16BIT0 PWME0 CAP1 T1CK1 T1CK0 T1CN T1ST
X 0 1 0 X X X X
PWM0HR
-
-
-
-
PWM03 PWM02 PWM01 PWM00 X X X X
Period high
Duty high
PWM[03:02] [0E5H] SCMR[1:0] Prescaler fXIN fSXIN
0X fEX 1X /1 /2 /8
[0E3H]
2 Bit T1PPR (8-bit)
T1CK[1:0] T1ST
00 01 10 11 2 Bit (note1) T1 (8-bit) clear Comparator
S R
Q POL0 PMR.6 [0D9H.6]
R31/T1O/PWM0 PIN
MUX T0 clock source (from Timer 0)
T1CN
2 Bit T1PDR (8-bit)
PWM[01:00]
2 Bit T1PDR (8-bit)
Note1: In the PWM mode, 2 bits are added by hardware automatically.
[0E5H]
[0E4H]
7 TM3
6
5
4
3
2
1
0 ADDRESS: 0E8H INITIAL VALUE: 00H ADDRESS: 0EBH INITIAL VALUE: 00H
BTCL POL1 16BIT1 PWME1 CAP3 T3CK1 T3CK0 T3CN T3ST
X 0 1 0 X X X X
PWM1HR
-
-
-
-
PWM13 PWM12 PWM11 PWM10 X X X X
Period high
Duty high
PWM[13:12] [0EBH] SCMR[1:0] Prescaler fXIN fSXIN
0X 1X /1 /2 /8
[0E9H]
2 Bit T3PPR (8-bit)
T3CK[1:0] T3ST
00 01 10 11 2 Bit (note1) T3 (8-bit) clear Comparator
S R
Q POL1 PMR.7 [0D9H.7]
R32/T3O/PWM1 PIN
MUX T2 clock source (from Timer 2)
T3CN
2 Bit T3PDR (8-bit)
PWM[11:10]
2 Bit T3PDR (8-bit)
[0EBH]
[0EAH]
Figure 13-12 PWM Mode
54
APR., 2001 Ver 2.01
GMS81C7008/7016
Note: Whenever change the register content of Period or Duty of PWM output, the timer counter Tn must be stopped and restart again by software.
The PWM0 will be explained in this chapter. Other PWM1 has same architecture. Pin R32/T1O/PWM0 outputs up to a 10-bit resolution PWM output. This pin should be configure as a PWM output to set bit PRM0.6 to "1". The period of the PWM output is determined by the T1PPR (PWM0 Period Register) and PWM0HR[3:2] and the duty is deter mi n ed b y t h e T1 P D R ( PWM 0 D u ty Re g is ter ) a nd PWM0HR[1:0].
The user writes the lower 8-bit period value to the T1PPR and the higher 2-bit period value to the PWM0HR[3:2]. And writes duty value to the T1PDR and the PWM0HR[1:0] same way. The T1PDR is configure as a double buffering for glitchless PWM output. In, the duty data is transferred from the master to the slave when the period data matched to the counted value. (i.e. at the beginning of next duty cycle) The relation between frequency and resolution is in inverse proportion. Table 13-1 shows the PWM frequency in each clock source. If it needed higher frequency of PWM, it should be reduced resolution.
PWM0HR
[0E5H]
- - - - 1110
T1PPR 11
[0E3H] 10
T1PDR
[0E4H]
11100111
01010111
Period
Duty
Period; (3E7H+1) x 500nS = 500uS
PWM output
Duty; (257H+1) x 500nS = 300uS
~ ~
~ ~
~~ ~~
~~ ~~
T1
00H
01H
02H
03H
04H
256H
257H
258H
3E7H
00H
01H
02H
~ ~
~ ~
Clock source
Figure 13-13 Example of Register setting The bit POL0 of TM0 decides the polarity of duty cycle. If the duty value is set same to the period value, the PWM output is determined by the bit POL0 (1: High, 0: Low). And if the duty value is set to "00H", the PWM output is determined by the bit POL0 (1: Low, 0: High). It can be changed duty value when the PWM output. However the changed duty value is output after the current period is over. And it can be maintained the duty value at present output when changed only period value shown as Figure 13-14. As it were, the absolute duty time is not changed in varying frequency. But the changed period value must greater than the duty value. At PWM output start command, one first pulse would be output abnormally. Because if user writes register values while timer is in operation, these register could be set with certain values at first. To prevent this operation, user must stop PWM timer clock and then set the duty and the period register values.
APR., 2001 Ver 2.01
55
GMS81C7008/7016
Example: Resolutio n 10-bit 9-bit 8-bit 7-bit PWM clock source fXIN/1 3.9kHz 7.8kHz 15.6kHz 31.2kHz fXIN/2 1.95kHz 3.9kHz 7.8kHz 15.6kHz fXIN/1024 3.8Hz 7.6Hz 15.3Hz 30.5Hz Timer1 = 2kHz, 30% duty PWM mode LDM LDM LDM LDM LDM TM1,#00H T1PPR,#0E8H T1PDR,#58H PWM0HR,0000_1110B TM1,#1010_1011B
Refer to Figure 13-13.
Table 13-1 PWM Frequency vs. Resolution at 4MHz
T1CK[1:0] = 10 (2uS) PWMHR = 00H T1PPR = 0DH T1PDR = 04H Write "09H" to T1PPR Period changed
Source clock T1 PWM POL=1
Duty Cycle [ (4+1) x 2uS = 10uS ] Period Cycle [ (DH+1) x 2uS = 28uS, 35.7kHz ] Duty Cycle [ (4+1) x 2uS =10uS ] Period Cycle [ (9+1) x 2uS = 20uS, 50kHz ] Duty Cycle [ (4+1) x 2uS = 10uS ] 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 00 01 02 03 04 05 06 07 08 09 00 01 02 03 04
Figure 13-14 Example of changing the period in absolute duty cycle at 4MHz
56
APR., 2001 Ver 2.01
GMS81C7008/7016
14. ANALOG DIGITAL CONVERTER
The analog-to-digital converter (A/D) allows conversion of an analog input signal to a corresponding 8-bit digital value. The A/ D module has eight analog inputs, which are multiplexed into one sample and hold. The output of the sample and hold is the input into the converter, which generates the result via successive approximation. The analog supply voltage is connected to AVDD of ladder resistance of A/D module. The A/D module has two registers which are the control register ADCM and A/D result register ADR. The register ADCM, shown in Figure 14-4, controls the operation of the A/D converter module. The port pins can be configured as analog inputs or digital I/ O. To use analog inputs, I/O is selected input mode by R2DD direction register.
How to Use A/D Converter
The processing of conversion is start when the start bit ADST is set to "1". After one cycle, it is cleared by hardware. The register ADR contains the results of the A/D conversion. When the conversion is completed, the result is loaded into the ADR, the A/D conversion status bit ADSF is set to "1", and the A/D interrupt flag AIF is set. The block diagram of the A/D module is shown in Figure 14-1. The A/D status bit ADSF is set automatically when A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 20 uS (at fXIN=4 MHz).
"0" AVDD "1" LADDER RESISTOR ADEN
ADS[2:0]
000
R20/AN0
001
R21/AN1 R22/AN2 R23/AN3 R24/AN4
101 010 011 100
8-bit DAC
S/H Sample & Hold
110 111
SUCCESSIVE APPROXIMATION CIRCUIT
ADIF
A/D INTERRUPT
R25/AN5 R26/AN6 R27/AN7
ADR A/D result register
ADDRESS: EDH RESET VALUE: Undefined
Figure 14-1 A/D Block Diagram
A/D Converter Cautions
(1) Input voltage range of AN0 to AN7 The input voltage of AN0 to AN7 should be within the specification range. In particular, if a voltage above AVDD or below AVSS is input (even if within the absolute maximum rating range), the conversion value for that channel can not be indeterminate. The conversion values of the other channels may also be affected. (2) Noise countermeasures In order to maintain 8-bit resolution, attention must be paid to noise on pins AVDD and AN0 to AN7. Since the effect increases in proportion to the output impedance of the analog input source, it is recommended that a capacitor be connected externally as shown in Figure 14-2 in order to reduce noise.
.
Analog Input 100~1000pF
AN0~AN7
Figure 14-2 Analog Input Pin Connecting Capacitor
APR., 2001 Ver 2.01
57
GMS81C7008/7016
(3) AD pin sharing with normal I/O port The analog input pins AN0 to AN7 also function as input/output port (PORT R20~R27) pins. When A/D conversion is performed with any of pins AN0 to AN7 selected, be sure not to execute a PORT input instruction while conversion is in progress, as this may reduce the conversion resolution. Also, if digital pulses are applied to a pin adjacent to the pin in the process of A/D conversion, the expected A/D conversion value may not be obtainable due to coupling noise. Therefore, avoid applying pulses to pins adjacent to the pin undergoing A/D conversion. (4) AVDD pin input impedance A series resistor string of approximately 10k is connected between the AVDD pin and the AVSS pin. Therefore, if the output impedance of the reference voltage source is high, this will result in parallel connection to the series resistor string between the AVDD pin and the AVSS pin, and there will be a large reference voltage error.
ENABLE A/D CONVERTER
A/D INPUT CHANNEL SELECT
ANALOG REFERENCE SELECT
A/D START ( ADST = 1 )
NOP NO ADSF = 1 YES READ ADR
Figure 14-3 A/D converter Operation Flow
-
R/W 6 ADEN
5 -
R/W 4
R/W
R/W
R/W
R ADDRESS: 0ECH INITIAL VALUE: -0-0 0001B A/D status bit 0: A/D conversion is in progress 1: A/D conversion is completed A/D start bit 0: 1: A/D start Setting this bit starts an A/D conversion. After one cycle, bit is cleared to "0" by hardware. Analog input channel select 000: Channel 0 (AN0) 001: Channel 1 (AN1) 010: Channel 2 (AN2) 011: Channel 3 (AN3) 100: Channel 4 (AN4) 101: Channel 5 (AN5) 110: Channel 6 (AN6) 111: Channel 7 (AN7)
ADCM
7 -
3 2 1 0 ADS2 BTCL ADS0 ADST ADSF ADS1
A/D converter Enable bit 0: A/D converter module turn off and current is not flow. 1: Enable A/D converter R 7 R 6 R 5 R 4 R 3 BTCL R 2 R 1 R 0
ADR
ADDRESS: 0EDH INITIAL VALUE: Undefined
A/D Conversion Data
Figure 14-4 A/D Converter Control Register
58
APR., 2001 Ver 2.01
GMS81C7008/7016
15. SERIAL COMMUNICATION
The serial interface is used to transmit/receive 8-bit data serially. Serial communication block consists of serial I/O data register, serial I/O mode register, clock selection circuit, octal counter and control circuit as illustrated in Figure 15-1.Pin R07/SIN, R06/ SOUT and R05/SCLK pins are controlled by the Serial Mode Register. The contents of the Serial I/O data register can be written into or read out by software. The serial communication is activated by the instruction "SET1 SCK1 0 0 1 1 SCK0 0 1 0 1 SCLK/R05 Port SCLK output SCLK output SCLK output SCLK input SIOST". The octal counter is reset to "0" by this instruction, starts counting at the falling or rising edge (by POL selection) of the transmit clock (SCLK), and it increments at the every clock. A serial interrupt request flag is set when the eighth transmit clock signal is input (the serial interface is reset) or when serial communication is discontinued (the octal counter is reset). The data in the Serial Data Register can be shifted synchronously with the transfer clock signal. Prescaler Divide Ratio /4 / 16 Use clock from Timer 0 overflow -
Clock Source Internal clock Internal clock Internal clock External clock
R/W
7
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R
0
SIOM
POL
MSB
SIO1
SIO0 BTCL SCK0 SIOST SIOSF SCK1
ADDRESS: 0FEH INITIAL VALUE: 0000_0001B Serial transmission status bit 0: Serial transmission is in progress 1: Serial transmission is completed Serial transmission start bit Setting this bit starts an Serial transmission. After one cycle, bit is cleared to "0" by hardware. Serial transmission Clock selection 00: fXIN / 4 01: fXIN / 16 10: Timer 0 Overflow 11: External Clock Serial transmission Operation Mode 00: Normal Port(R05,R06,R07) 01: Sending Mode(SCLK,SOUT,R07) 10: Receiving Mode(SCLK,R06,SIN) 11: Sending & Receiving Mode(SCLK,SOUT,SIN) Selection Polarity 0: Data in on rising edge, data out on falling edge 1: Data in on falling edge, data out on rising edge
MSB first or LSB first 0: LSB First 1: MSB First
R/W R/W R/W R/W R/W R/W R/W R/W
7 6 5 4 3 2 1 0
SIOR
BTCL
ADDRESS: 0FFH INITIAL VALUE: Undefined
Sending Data during Sending Mode Receiving Data during Receiving Mode
Figure 15-1 SCI Control Register
APR., 2001 Ver 2.01
59
GMS81C7008/7016
Serial I/O Mode Register(SIOM) controls serial I/O function. The POL bit control which edge
According to SCK1 and SCK0, the internal clock or external clock can be selected. Serial I/O Data Register(SIOR) is an 8-bit shift register.
SCMR[1:0] Prescaler fXIN fSXIN T0OV (Timer 0 overflow) R05/SCLK PIN SIO[1:0]
0X 1X /4
SCK[1:0]
POL
SIOST
start
SIOSF
complete clear
00 01 Edge Detector 10 11 MUX
/16
CONTROL CIRCUIT
shift clock clock
Octal Counter
SIOIF overflow Serial communication Interrupt
SCLK OUT
SCK, SIO
Serial IO Data R07/SIN PIN [0FFH] SIO1 SIO0
R06/SOUT PIN
Figure 15-2 Block Diagram of SCI
15.1 Transmission/Receiving Timing
The serial transmission is started by setting SIOST(bit1 of SIOM) to "1". After one cycle of SCK, SIOST is cleared automatically to "0". The serial output data from 8-bit shift register is output at falling edge of SCLK. And input data is latched at rising edge of SCLK pin. When transmission clock is counted 8 times, serial I/O counter is cleared as `0". Transmission clock is halted in "H" state and serial I/ O interrupt(SIOIF) occurred.
SIOST
SCLK [R05] (POL=0)
SOUT [R06] SIN [R07]
D0
D1
D2
D3
D4
D5
D6
D7
D0
D1
D2
D3
D4
D5
D6
D7
SIOSF SIOIF (Interrupt Req.)
Figure 15-3 SPI Timing Diagram at POL=0
60
APR., 2001 Ver 2.01
GMS81C7008/7016
15.2 The method of Serial I/O
1. Select transmission/receiving mode When external clock is used, the frequency should be less than 1MHz and recommended duty is 50%. 2. In case of sending mode, write data to be send to SIOR. 3. Set SIOST to "1" to start serial transmission. If both transmission mode is selected and transmission is performed simultaneously it would be made error. 4. The SIO interrupt is generated at the completion of SIO and SIOSF is set to "1". In SIO interrupt service routine, correct transmission should be tested. 5. In case of receiving mode, the received data is acquired by reading the SIOR.
SIOST SCLK [R05] (POL=1)
SOUT [R06] SIN [R07]
D0
D1
D2
D3
D4
D5
D6
D7
D0
D1
D2
D3
D4
D5
D6
D7
SIOSF
SCIIF
Figure 15-4 SPI Timing Diagram at POL=1
15.3 The Method to Test Correct Transmission
Serial I/O Interrupt Service Routine 0
SIOSF 1 SE = 0
Abnormal
Write SIOM
- SE : Interrupt Enable Register Low IENL(Bit3) - SR : Interrupt Request Flag Register Low IRQL(Bit3)
SR 1 Normal Operation
0
Overrun Error
Figure 15-5 Serial Method to Test Transmission
APR., 2001 Ver 2.01
61
GMS81C7008/7016
16. BUZZER FUNCTION
The buzzer driver block consists of 6-bit binary counter, buzzer register, and clock source selector. It generates square-wave which has very wide range frequency (500Hz ~ 250kHz at fXIN= 4MHz) by user software. A 50% duty pulse can be output to R30/BUZ pin to use for piezoelectric buzzer drive. Pin R30 is assigned for output port of Buzzer driver by setting the bit 5 of PMR (address D9H) to "1". At this time, the pin R30 must be defined as output mode (the bit 0 of R3DD=1). Example: 2.4kHz output at 4MHz. LDM LDM SET1 CLR1
X means don't care
The bit 0 to 5 of BUR determines output frequency for buzzer driving. Equation of frequency calculation is shown below. f XIN f BUZ = --------------------------------------------------------------------------------------2 x DivideRatio x ( BUR [ 5:0 ] + 1 )
fBUZ: Buzzer frequency fXIN: Oscillator frequency Divide Ratio: Prescaler divide ratio by BUCK[1:0] BUR: Lower 6-bit value of BUR. Buzzer period value.
R3DD,#XXXX_XXX1B BUR,#0111_0011B PMR.5 PMR.5 ;BUZ ON ;BUZ OFF
The frequency of output signal is controlled by the buzzer control register BUR.The BUR[5:0] determine output frequency for buzzer driving.
BUR[7:6] SCMR[1:0] fXIN fSXIN Prescaler
0X 1X
/8 /16 /32 /64
R30 port data 00 01 10 11 MUX Comparator 6-bit Compare Data BUR[5:0] [0FDH] /2 F/F 0 1 PMR.5 6-bit Binary Counter
R30/BUZ PIN
Figure 16-1 Block Diagram of Buzzer Driver
ADDRESS: 0D9H RESET VALUE: 00H
R/W R/W R/W R/W R/W R/W R/W R/W
ADDRESS: 0FDH RESET VALUE: Undefined W W W W W W W W
PMR
PWM1 PWM0
BUZ EC2 EC0 INT2 INT1 INT0
BUR
BUCK1 BUCK0
R30/BUZ Selection 0: R30 port (Turn off buzzer) 1: BUZ port (Turn on buzzer)
BUR[5:0] Define Frequency of Buzzer signal Source clock select 00: / 8 01: / 16 10: / 32 11: / 64
Figure 16-2 PMR and Buzzer Register
62
APR., 2001 Ver 2.01
GMS81C7008/7016
Note that BUR is a write-only register. The 6-bit counter is cleared and starts the counting by writing signal at BUR register. It is incremental from 00H until it matches 6BUR [5:0] 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F BUCK[1:0] 00 250.000 125.000 83.333 62.500 50.000 41.667 35.714 31.250 27.778 25.000 22.727 20.833 19.231 17.857 16.667 15.625 14.706 13.889 13.158 12.500 11.905 11.364 10.870 10.417 10.000 9.615 9.259 8.929 8.621 8.333 8.065 7.813 01 125.000 62.500 41.667 31.250 25.000 20.833 17.857 15.625 13.889 12.500 11.364 10.417 9.615 8.929 8.333 7.813 7.353 6.944 6.579 6.250 5.952 5.682 5.435 5.208 5.000 4.808 4.630 4.464 4.310 4.167 4.032 3.906 10 62.500 31.250 20.833 15.625 12.500 10.417 8.929 7.813 6.944 6.250 5.682 5.208 4.808 4.464 4.167 3.906 3.676 3.472 3.289 3.125 2.976 2.841 2.717 2.604 2.500 2.404 2.315 2.232 2.155 2.083 2.016 1.953 11 31.250 15.625 10.417 7.813 6.250 5.208 4.464 3.906 3.472 3.125 2.841 2.604 2.404 2.232 2.083 1.953 1.838 1.736 1.645 1.563 1.488 1.420 1.359 1.302 1.250 1.202 1.157 1.116 1.078 1.042 1.008 0.977
bit BUR value. When main-frequency is 4MHz, buzzer frequency is shown as below table. The unit is kHz. BUR [5:0] 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F BUCK[1:0] 00 7.576 7.353 7.143 6.944 6.757 6.579 6.410 6.250 6.098 5.952 5.814 5.682 5.556 5.435 5.319 5.208 5.102 5.000 4.902 4.808 4.717 4.630 4.545 4.464 4.386 4.310 4.237 4.167 4.098 4.032 3.968 3.906 01 3.788 3.676 3.571 3.472 3.378 3.289 3.205 3.125 3.049 2.976 2.907 2.841 2.778 2.717 2.660 2.604 2.551 2.500 2.451 2.404 2.358 2.315 2.273 2.232 2.193 2.155 2.119 2.083 2.049 2.016 1.984 1.953 10 1.894 1.838 1.786 1.736 1.689 1.645 1.603 1.563 1.524 1.488 1.453 1.420 1.389 1.359 1.330 1.302 1.276 1.250 1.225 1.202 1.179 1.157 1.136 1.116 1.096 1.078 1.059 1.042 1.025 1.008 0.992 0.977 11 0.947 0.919 0.893 0.868 0.845 0.822 0.801 0.781 0.762 0.744 0.727 0.710 0.694 0.679 0.665 0.651 0.638 0.625 0.613 0.601 0.590 0.579 0.568 0.558 0.548 0.539 0.530 0.521 0.512 0.504 0.496 0.488
Table 16-1 Buzzer Frequency at 4MHz
APR., 2001 Ver 2.01
63
GMS81C7008/7016
17. INTERRUPTS
The GMS81C7008/16 interrupt circuits consist of Interrupt enable register (IENH, IENL), Interrupt request flags of IRQH, IRQL, Priority circuit, and Master enable flag ("I" flag of PSW). Thirteen interrupt sources are provided. The configuration of interrupt circuit is shown in Figure 17-2. The keyscan interrupt is generated when 1-to-0 transition is detected at KS0 or KS0 pin. The Basic Interval Timer Interrupt is generated by BITIF which is set by an overflow in the timer register. The Watchdog timer Interrupt is generated by WDTIF which set by a match in Watchdog timer register. The External Interrupts INT0 ~ INT2 each can be transition-activated (1-to-0 or 0-to-1 transition) by selection IEDS. The flags that actually generate these interrupts are bit INT0IF, INT1IF and INT2IF in register IRQH and IRQL. When an external interrupt is generated, the flag that generated it is cleared by the hardware when the service routine is vectored to only if the interrupt was transition-activated. The Timer 0 ~ Timer 3 Interrupts are generated by T0IF~T3IF which are set by a match in their respective timer/counter register. The Serial Communication Interrupts are generated by SIOIF which is set by 8-bit serial data transmitting or receiving through SCK, SIN, SOUT pin. The AD converter Interrupt is generated by ADIF which is set by finishing the analog to digital conversion. The Watch Timer Interrupt is generated by WTIF which is set by an 14-bit binary counter overflow. The interrupts are controlled by the interrupt master enable flag I-flag (bit 2 of PSW on page 19), the interrupt enable register (IENH, IENL), and the interrupt request flags (in IRQH and IRQL) except Power-on reset and software BRK interrupt. Below table shows the Interrupt priority. Reset/Interrupt Hardware Reset Key scan Interrupt Basic Interval Timer Watchdog Timer External Interrupt 0 External Interrupt 1 Timer/Counter 0 Timer/Counter 1 External Interrupt 2 Serial Communication ADC Interrupt Watch Timer Interrupt Timer/Counter 2 Timer/Counter 3 Symbol RESET KS BIT WDT INT0 INT1 Timer 0 Timer 1 INT2 SCI ADC WT Timer 2 Timer 3 Priority 1 2 3 4 5 6 7 8 9 10 11 12 13
Vector addresses are shown in Figure 8-6 on page 21. Interrupt enable registers are shown in Figure 17-3. These registers are composed of interrupt enable flags of each interrupt source and these flags determines whether an interrupt will be accepted or not. When enable flag is "0", a corresponding interrupt source is prohibited. Note that PSW contains also a master enable bit, Iflag, which disables all interrupts at once.
R/W
-
-
R/W
SIOIF
R/W
ADIF
R/W
WTIF
R/W T2IF
R/W T3IF LSB
IRQL
INT2IF
ADDRESS: 0DCH INITIAL VALUE: 0--0 0000B Timer/Counter 3 Timer/Counter 2 Watch timer A/D Converter
MSB External interrupt 2 Serial Communication
-
R/W
KSIF
R/W
R/W
R/W
R/W
R/W
R/W T1IF LSB
IRQH
MSB Key scan Basic Interval Timer Watchdog timer
-
BITIF WDTIF INT0IF INT1IF T0IF
ADDRESS: 0DDH INITIAL VALUE: -000 0000B Timer/Counter 1 interrupt request flag Timer/Counter 0 External interrupt 1 External interrupt 0
Figure 17-1 Interrupt Request Flag
64
APR., 2001 Ver 2.01
GMS81C7008/7016
.
Internal bus line I-flag is in PSW, it is cleared by "DI", set by "EI" instruction. When it goes interrupt service, I-flag is cleared by hardware, thus any other interrupt are inhibited. When interrupt service is completed by "RETI" instruction, I-flag is set to "1" by hardware.
[0DAH] IRQL [0DCH] INT2 Serial Communication A/D Converter Watch Timer Timer 2 Timer 3 IRQH [0DDH] Key Scan BIT Watchdog Timer INT0 INT1 Timer 0 Timer 1 KSIF BITIF WDTIF INT0IF INT1IF T0IF T1IF INT2IF SIOIF ADIF WTIF
IENL
Interrupt Enable Register (Lower byte)
Release STOP
Priority Control
T2IF T3IF
To CPU
I-flag Interrupt Master Enable Flag Interrupt Vector Address Generator
[0DBH]
IENH
Interrupt Enable Register (Higher byte)
Internal bus line
Figure 17-2 Block Diagram of Interrupt
R/W -
-
R/W
SIOE
R/W ADE
R/W WTE
R/W T2E
R/W T3E LSB
IENL
INT2E
ADDRESS: 0DAH INITIAL VALUE: 0--0 0000B Timer/Counter 3 interrupt enable flag Timer/Counter 2 interrupt enable flag Watch Timer interrupt enable flag A/D Converter interrupt enable flag Serial Communication interrupt enable flag External interrupt 2 enable flag
MSB
-
R/W
KSE
R/W
BITE
R/W
R/W
R/W
R/W T0E
R/W T1E LSB
IENH
MSB
-
WDTE INT0E INT1E
ADDRESS: 0DBH INITIAL VALUE: -000 0000B Timer/Counter 1 interrupt enable flag Timer/Counter 0 interrupt enable flag External interrupt 1 enable flag External interrupt 0 enable flag Watchdog timer interrupt enable flag Basic Interval Timer interrupt enable flag Key scan interrupt enable flag
VALUE 0: Disable 1: Enable
Figure 17-3 Interrupt Enable Flag
APR., 2001 Ver 2.01
65
GMS81C7008/7016
17.1 Interrupt Sequence
An interrupt request is held until the interrupt is accepted or the interrupt latch is cleared to "0" by a reset or an instruction. Interrupt acceptance sequence requires 8 fXIN (2 s at fMAIN=4.19MHz) after the completion of the current instruction execution. The interrupt service task is terminated upon execution of an interrupt return instruction [RETI].
2. Interrupt request flag for the interrupt source accepted is cleared to "0". 3. The contents of the program counter (return address) and the program status word are saved (pushed) onto the stack area. The stack pointer decreases 3 times. 4. The entry address of the interrupt service program is read from the vector table address and the entry address is loaded to the program counter. 5. The instruction stored at the entry address of the interrupt service program is executed.
Interrupt acceptance 1. The interrupt master enable flag (I-flag) is cleared to "0" to temporarily disable the acceptance of any following maskable interrupts. When a non-maskable interrupt is accepted, the acceptance of any following interrupts is temporarily disabled.
System clock
Instruction Fetch Address Bus
PC SP SP-1 SP-2 V.L. V.H. New PC
Data Bus Internal Read Internal Write
Not used
PCH
PCL
PSW
V.L.
ADL
ADH
OP code
Interrupt Processing Step V.L. and V.H. are vector addresses. ADL and ADH are start addresses of interrupt service routine as vector contents.
Interrupt Service Task
Figure 17-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction When nested interrupt service is required, the I-flag should be set to "1" by "EI" instruction in the interrupt service program. In this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags.
Watch Timer Vector Table Address
Entry Address
0FFE4H 0FFE5H
012H 0E3H
0E312H 0E313H
0EH 2EH
Saving/Restoring General-purpose Register
Correspondence between vector table address for Watch Timer Interrupt and the entry address of the interrupt service program.
A interrupt request is not accepted until the I-flag is set to "1" even if a requested interrupt has higher priority than that of the current interrupt being serviced.
During interrupt acceptance processing, the program counter and the program status word are automatically saved on the stack, but accumulator and other registers are not saved itself. These registers are saved by the software if necessary. Also, when multiple interrupt services are nested, it is necessary to avoid using the same data memory area for saving registers. The following method is used to save/restore the general-purpose registers.
66
APR., 2001 Ver 2.01
GMS81C7008/7016
Example: Register save using push and pop instructions INTxx: PUSH PUSH PUSH A X Y ;SAVE ACC. ;SAVE X REG. ;SAVE Y REG.
17.3 Multi Interrupt
If two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the interrupt are received at the same time simultaneously, an internal polling sequence determines by hardware which request is serviced. However, multiple processing through software for special features is possible. Generally when an interrupt is accepted, the Iflag is cleared to disable any further interrupt. But as user sets Iflag in interrupt routine, some further interrupt can be serviced even if certain interrupt is in progress.
interrupt processing
POP POP POP RETI
Y X A
;RESTORE Y REG. ;RESTORE X REG. ;RESTORE ACC. ;RETURN
General-purpose register save/restore using push and pop instructions;
Example: During Timer1 interrupt is in progress, INT0 interrupt serviced without any suspend. TIMER1: PUSH PUSH PUSH LDM LDM EI : : : : LDM LDM POP POP POP RETI .
Main Program service
main task acceptance of interrupt interrupt service task saving registers
A X Y IENH,#08H IENL,#00H
;Enable INT0 only ;Disable other ;Enable Interrupt
restoring registers interrupt return
17.2 BRK Interrupt
Software interrupt can be invoked by BRK instruction, which has the lowest priority order. Interrupt vector address of BRK is shared with the vector of TCALL 0 (Refer to Program Memory Section). When BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from TCALL 0. Each processing step is determined by B-flag as shown in Figure 17-5.
IENH,#0FFH ;Enable all interrupts IENL,#0FFH Y X A
TIMER 1 service INT0 service
enable INT0 disable other EI
Occur TIMER1 interrupt =0
Occur INT0
B-FLAG BRK or TCALL0 =1 BRK INTERRUPT ROUTINE RETI
TCALL0 ROUTINE
enable INT0 enable other
RET In this example, the INT0 interrupt can be serviced without any pending, even TIMER1 is in progress. Because of re-setting the interrupt enable registers IENH,IENL and master enable "EI" in the TIMER1 routine.
Figure 17-5 Execution of BRK/TCALL0
Figure 17-6 Execution of Multi Interrupt
APR., 2001 Ver 2.01
67
GMS81C7008/7016
17.4 External Interrupt
The external interrupt on INT0, INT1 and INT3 pins are edge triggered depending on the edge selection register IEDS (address 0D8H) as shown in Figure 17-7. The edge detection of external interrupt has three transition activated mode: rising edge, falling edge, and both edge. Example: To use as an INT0 and INT2 : : ;**** Set port as an input port R00,R02 LDM R0DD,#1111_1010B ; ;**** Set port as an external interrupt port LDM PMR,#05H ; ;**** Set Falling-edge Detection LDM IEDS,#0001_0001B : :
INT0 pin
INT0IF INT0 INTERRUPT
INT1 pin
INT1IF INT1 INTERRUPT
Response Time
The INT0 ~ INT2 edge are latched into INT1IF ~ INT2IF at every machine cycle. The values are not actually polled by the circuitry until the next machine cycle. If a request is active and conditions are right for it to be acknowledged, a hardware subroutine call to the requested service routine will be the next instruction to be executed. The DIV itself takes twelve cycles. Thus, a minimum of twelve complete machine cycles elapse between activation of an external interrupt request and the beginning of execution of the first instruction of the service routine. Figure 17-8 shows interrupt response timings.
INT2 pin
INT2IF INT2 INTERRUPT
2
2
2 Edge selection Register
IEDS [0D8H]
Figure 17-7 External Interrupt Block Diagram INT0 ~ INT2 are multiplexed with general I/O ports (R00~R02). To use as an external interrupt pin, the bit of Port Mode Register PMR should be set to "1" correspondingly as shown in Figure 179.
max. 12 fXIN period
8 fXIN period
Interrupt Interrupt goes latched active
Interrupt processing
Interrupt routine
Figure 17-8 Interrupt Response Timing Diagram
17.5 Key Scan Interrupt
GMS81C7008/16 has the key-scan block which consists of Port selection Multiplexer, Interrupt controller, Key scan mode register and Falling edge detector shown as Figure 17-10. When the key scan interrupt is used, key scan register KSMR (address 0F0H) should be set to "1" as KS0 and KS1. After reset, initial setting is general R10 and R00 ports. If key scan is detected at any one or more of these pins, the KSIF request flag is set to "1". This generates an interrupt request. It also can be used in the way of release from STOP mode.
68
APR., 2001 Ver 2.01
GMS81C7008/7016
R/W
R/W
R/W BUZ
R/W
R/W
R/W
R/W
R/W ADDRESS: 0D9H INITIAL VALUE: 00H
PMR
PWM1 PWM0 MSB
EC2S BTCL INT2S INT1S INT0S EC0S
0: R32 1: PWM1/T3O 0: R31 1: PWM0/T1O 0: R30 1: BUZ 0: R04 1: EC2 MSB -
LSB 0: R00 1: INT0 0: R01 1: INT1 0: R02 1: INT2 0: R03 1: EC0 LSB R/W ADDRESS: 0D8H INITIAL VALUE: 00H
-
R/W
R/W
R/W
R/W
R/W
IEDS
-
BTCL IED2H IED2L IED1H IED1L IED0H IED0L INT2 INT1 INT0
Edge selection register 00: Reserved 01: Falling (1-to-0 transition) 10: Rising (0-to-1 transition) 11: Both (Rising & Falling)
Figure 17-9 PMR and IEDS Registers
.
Key Scan Mode Register KSMR
Pull up Resistor Typ. 160k VDD [0F0H] KSMR R1PU[1:0] Edge detector R10/KS0 KSIF R11/KS1 Reserved -
ADDRESS: 0F0H RESET VALUE: 00H KS1 KS0
Port selection 0: R10 1: KS0 Port selection 0: R11 1: KS1
Key Scan Interrupt
Figure 17-10 Key Scan Port Block Diagram
APR., 2001 Ver 2.01
69
GMS81C7008/7016
18. LCD DRIVER
The GMS81C7008/16 has the circuit that directly drives the liquid crystal display (LCD) and its control circuit. In addition, VCLn pin is provided as the drive power pin. GMS81C7008/16 1/4 duty: 1/3 duty: 1/2 duty: Static: 24 seg x 4com 25 seg x 3com 26 seg x 2com 27 seg x 1com Basically, the GMS81C7008/16 has 24 seg.x 4 com. ports of LCD driver. Extend display modes are shown in left table. Figure 18-1shows the configuration of the LCD driver.
********Caution******** When you developing the software using by Emulator, you must select the External bias resistor mode because of no internal bias resistor inside the Emulator (EVA. chip).
Select SEG or Normal port by LPMR [0F2H] SEG0/R40
Display Data Select Control
Display Data Buffer register
R4 or Segment
SEG7/R47
Segment Driver
LPMR[1:0] SEG8/R50
"Same with above"
Display Memory (27 x 4 bits)
LPMR[3:2]
"Same with above"
SEG15/R57 SEG16/R60
INTERNAL BUS LINE
LPMR[5:4] WTCK[1:0] LCD Timing Control / 32 fSUB fMAIN/27
00 01
SEG23/R67
Prescaler
/ 128 MUX / 256
Common Driver
COM. or SEG.
/ 64
COM0 COM1/SEG26 COM2/SEG25 COM3/SEG24
M UX
LCR[3:2] of address 0F1H Power & Bias control
Control frame frequency
LCR
Enable LCD Control bias voltage and resistor
BIAS VCL2 VCL1 VCL0
[0F1H]
Figure 18-1 LCD Driver Block Diagram
18.1 LCD Control Registers
The LCD driver is controlled by the LCD control register LCR which is shown in Figure 18-2. LCD block input the clock from
70
APR., 2001 Ver 2.01
GMS81C7008/7016
the Watch Timer. When LCD is operate, the Watch Timer much
be enabled by WTEN (bit 6 of address 0EFH).
R/W 7
R/W 6
R/W 5
R/W 4
R/W 3
R/W 2
R/W 1
R/W 0
LCR
SUBM
BTC LCDEN BRC DTY1 DTY0 LCK1 LCK0
ADDRESS: 0F1H INITIAL VALUE: 00H
Sub clock port mode 0: SXIN, SXOUT 1: R35, R36
Selection frame frequency 00: 1024Hz When 01: 512Hz fXIN = 4.19MHz 10: 256Hz fSXIN = 32.768kHz 11: 128Hz Duty control 00: 1/4 duty 01: 1/3 duty (SEG24 active) 10: 1/2 duty (SEG24, SEG25 active) 11: Static (SEG24, SEG25, SEG26 active) Bias resistor control 0: External 1: Internal No internal bias registers in the Emulator, so user must select the "0", External mode at least during use the Emulator. OTP and Mask MCU can use both. R/W R/W 3 2 R5LPMR R/W R/W 1 0 R4LPMR
Bias transistor control 0: off 1: on LCD display control 0: LCD display all segment 0 data output 1: LCD display enable
LPMR
R/W 7 -
R/W 6 -
R/W R/W 5 4 R6LPMR
ADDRESS: 0F2H INITIAL VALUE:0000 0000
R4 port selection 00:SEG0~SEG7 01:SEG4~SEG7,R40~R43 10:SEG0~SEG3,R44~R47 11:R40~R47 R5 port selection 00:SEG8~SEG15 01:SEG12~SEG15,R50~R53 10:SEG8~SEG11,R54~R57 11:R50~R57 R6 port selection 00:SEG16~SEG23 01:SEG20~SEG23,R60~R63 10:SEG16~SEG19,R64~R67 11:R60~R67 7
6
5
4
3
R/W
2 1
R/W
0
RPR
-
-
-
-
-
-
RPR1 RPR0
ADDRESS: 0F3H INITIAL VALUE: 00H
The RPR register is used for RAM page selection. RAM page Page 0 Page 0 Page 1 Reserved Reserved Instruction CLRG SETG SETG SETG SETG PRP1 X 0 0 1 1 PRR0 X 0 1 0 1
Figure 18-2 LCD Control Register
APR., 2001 Ver 2.01
71
GMS81C7008/7016
18.2 Duty and Bias Selection of LCD driver
5 kinds of driving methods can be selected by DTY (bits 3 and 2 of LCD Control Register and connection of VCL pin externally. Figure 18-3 shows typical driving waveforms for LCD.).
VCL2 VCL1 VCL0 GND -VCL0 -VCL1 -VCL2
1/fF
VCL2 VCL1 VCL0 GND -VCL0 -VCL1 -VCL2 Data "0"
1/fF
Data "1"
Data "1"
Data "0"
(a) 1/4 duty, 1/3 bias
VCL2 VCL1 VCL0 GND -VCL0 -VCL1 -VCL2 VCL2 VCL1 = VCL0 GND -VCL0 = -VCL1 -VCL2 Data "1" Data "0"
(b) 1/3 duty, 1/3 bias
1/fF
1/fF
Data "1" Data "0"
(c) 1/2 duty,1/3 bias
VCL2 VCL1 VCL0 GND -VCL0 -VCL1 -VCL2 1/fF
(d) 1/2 duty, 1/2 bias
Note: fF: LCD Frame Frequency
Data "1"
Data "0"
(e) Static
Figure 18-3 LCD drive waveform (Voltage COM-SEG Pins)
18.3 Selecting Frame Frequency
Frame frequency is set to the base frequency as shown in the following Table 18-1. The LCK[1:0] of LCR determines the frequency of COM signal scanning of each segment output. The watch timer must be enabled when the LCD display is turned on. RESET clears the LCD control register LCR values to logic zero. The LCD display can continue to operate even during the SLEEP and STOP modes if a sub-frequency clock is oscillate and used as clock source of LCD driver. . LCK[1:0] 00 01 10 11 LCD clock fSUB / 32 fSUB / 64 fSUB / 128 fSUB / 256 Frame Frequency (Hz)
(When fSUB = 32.768 kHz)
1024 512 256 128
Table 18-1 Setting of LCD Frame Frequency
72
APR., 2001 Ver 2.01
GMS81C7008/7016
COM0 pin
one frame (at 1/4 duty, 1/3 bias)
LCD Port Selection
Segment pins are also used for normal I/O pins. The LCD port selection register LPMR is used to set Rn pin for ordinary digital input. Refer to LPMR register as shown in Figure 18-2.
Bias Resistor
To operate LCD, built-in Bias resistor dividing VDD to VSS section into several stages generates necessary voltage.
The BTC (Bit 6 of LCR) switches Transistor supplying voltage to serially connected Bias resistor. If it is `1', it turns on, and if it is `0', it turns off. The LCD drive voltage (VCL2) is given by the difference in potential (VDD-VCL2) between pins VDD and VCL2. Therefore, when the MCU operating voltage is 5V and LCD drive voltage are the same, the Bias pin is connected to the VCL2 pin as shown in (a) of Figure 18-5.
MCU Internal
VDD BTC
MCU Internal
VDD BTC
2R Internal Bias resistors
BIAS Internal Bias resistors
2R
BIAS
R
VCL2
Two pins are connected each other VCL2=5V VCL1=3.33V VCL0=1.67V
R
VCL2
Short two pins each other externally VCL2=5V VCL1=2.5V VCL0=2.5V
R
VCL1
R
VCL1
R VSS BRC
VCL0
R VSS BRC
VCL0
BTC = "1"
BRC = "1"
BTC = "1"
BRC = "1"
Typ. R=65k
(a) Internal, Static or 1/3 Bias
(b) Internal, Static or 1/2 Bias
Figure 18-4 Application Example of 5V LCD Panel When require supply 3V output to the LCD, the voltage of V CL2 becomes 3V as shown in Figure 18-5. Because VDD is down to 3V through internal 2R resistor. The LCD light only when the difference in potential between the segment and common output is VCL, and turn off at all other times. During reset, the power switch of the LCD driver is turned off automatically, shutting off the VCL voltage.
APR., 2001 Ver 2.01
73
GMS81C7008/7016
MCU Internal
VDD = 5V BTC
MCU Internal
VDD = 5V BTC
2R Internal Bias resistors Typ. R=65k
BIAS
R
VCL2
Internal Bias resistors
VCL2=3V VCL1=2V VCL0=1V
2R
BIAS
VCL2=3V VCL1=1.5V VCL0=1.5V
R
VCL2
R
VCL1
R
VCL1
Short two pins externally
R VSS BRC
VCL0
R VSS BRC
VCL0
BTC = "1"
BRC = "1"
BTC = "1"
BRC = "1"
Typ. R=65k
(a) Internal, Static or 1/3 Bias
(b) Internal, Static or 1/2 Bias
Figure 18-5 Application Example of 3V LCD Panel Some user want to use external bias resisor instead of internal, you can connect external resistor as shown in Figure 18-6. And the external capacitors are may required for stable display according to your system environment.
MCU Internal
VDD BTC
BTC = "0"
2R Internal Bias resistors BIAS
VDD Adjust Contrast VCL2
R
R
VCL1
R
VCL0 VSS External circuit
BRC = "0"
BRC
VSS
Figure 18-6 External Resistor
74
APR., 2001 Ver 2.01
GMS81C7008/7016
18.4 LCD Display Memory
Display data are stored to the display data area (address 100H-11AH) in the data memory. The display data stored to the display data area are read automatically and sent to the LCD driver by the hardware. The LCD driver generates the segment signals and common signals in accordance with the display data and drive method.
Bit 0 SEG26 SEG25 SEG24 SEG23 SEG22 SEG21 SEG20 SEG19 SEG18 SEG17 Note: The bit 4 to 7 of every byte are reserved. Any read or write is not effect. SEG16 SEG15 SEG14 SEG13 SEG12 SEG11 SEG10 SEG9 SEG8 SEG7 SEG6 SEG5 SEG4 SEG3 SEG2 SEG1 SEG0
1
2
3
4
5
6
7 11AH 119H 118H 117H 116H 115H 114H 113H 112H 111H 110H 10FH 10EH 10DH 10CH 10BH 10AH 109H 108H 107H 106H 105H 104H 103H 102H 101H 100H
COM0
COM1
COM2
Figure 18-7 LCD Display Memory
COM3
Therefore, display patterns can be changed by only overwriting the contents of the display data area with a program. The table look up instruction is mainly used for this overwriting. Figure 18-7 shows the correspondence between the display data area and the SEG/COM pins. The LCD lights when the display data is "1" and turn off when "0". The number of segment which can be driven differs depending on the LCD drive method, therefore, the number of display data area bits used to store the data also differs
(Refer to Figure 18-2). Consequently, data memory not
Drive methods 1/4 duty 1/3 duty 1/2 duty Static Bit 3 COM3 Bit 2 COM2 COM2 Bit 1 COM1 COM1 COM1 Bit 0 COM0 COM0 COM0 COM0
Table 18-2 The duty vs. COM port Configuration
APR., 2001 Ver 2.01
75
GMS81C7008/7016
used to store display data and data memory for which the address are not connected to LCD can be used to store ordinary user's processing data. Blanking
Blanking is applied by setting LCDEN (bit 7 of LCR) to "0" and
turns off the LCD by outputting the non light operation level to the COM pin. When setting Frame frequency or changing operating mode, LCD display should be off before operation, to prevent display flickering.
18.5 Control Method of LCD Driver
Initial Setting Flow chart of initial setting is shown in Figure 18-8. Example: When operating with 1/4 duty LCD using a
Select Frame Frequency
frame frequency of 512Hz.
LDM : SETG LDM
LCR,#0101_0001B ;1/4duty, fF=512Hz (fSUB= 32.768kHz) RPR,#1 #0 #0 {X}+ #01BH C_LCD1 ;Select LCD Memory ;area (Page 1 = address 1XXH) ;RAM Clear ;RAM(100H~11AH)
Clear LCD Display Memory
LDX C_LCD1: LDA STA CMPX BNE CLRG : : SET1 : :
Turn on LCD
LCR.5
;Enable LCD display
.
COM0 COM1 Setting of LCD drive method COM2 SEG0 Initialize of display memory SEG1 Example: display "2" Enable display (Release of blanking)
bit 7 6 5 4 3 2 1 0
COM3
100H 101H
* *
* *
* *
* *
0 1
0 1
1 1
1 0
Note: * are don't care.
Figure 18-8 Initial Setting of LCD Driver
Figure 18-9 Example of Connection COM & SEG
Display Data Setting Normally, display data are kept permanently in the program memory and then stored at the display data area by the table look-up instruction. This can be explained using numerical display with 1/4 duty LCD as an example. The COM and SEG connections to the LCD and display data are the same as those shown is Figure 18-9. Programming
76
APR., 2001 Ver 2.01
GMS81C7008/7016
example for displaying character is shown below.
: CLRG LDX LDA TAY LDA LDM SETG LDX STA XCN STA CLRG : :
GOLCD: Write into the LCD Memory
#DISPRAM {X} !FONT+Y RPR,#1 #0 {X}+ {X} ;LOAD FONT DATA ;Set RPR = 1 to access LCD ;Set Page 1 ;LOWER 4 BITS OF ACC. -> M(X) ;UPPER 4 BITS OF ACC. -> M(X+1) ;Set Page = 0
Font data
FONT
DB DB DB DB DB DB DB DB DB DB
1101_0111B 0000_0110B 1110_0011B 1010_0111B 0011_0110B 1011_0101B 1111_0101B 0000_0111B 1111_0111B 0011_0111B
; ; ; ; ; ; ; ; ; ;
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
Note: When power on RESET, sub oscillation start up time is required. Enable LCD display after sub oscillation is stabilized, or LCD may occur flicker at power on time shortly.
APR., 2001 Ver 2.01
77
GMS81C7008/7016
19. WATCH / WATCHDOG TIMER
19.1 Watch Timer
The watch timer goes the clock continuously even during the power saving mode. When MCU is in the Stop or Sleep mode, MCU can wake up itself every 2Hz or 4Hz or 16Hz. The watch timer consists of input clock selector, 14-bit binary counter, interval selector and Watch Timer Mode Register WTMR (address 0EFH). The WTMR is 5-bit read/write register and shown in Figure 19-2. WTMR can select the clock input by 2 bits WTCK[1:0] and interval time selector by 2 bits WTIN[1:0] and enable/disable bit. The WTEN bit is set to "1" timer start counting. Input clocks can be selected among three different source which are sub clock or divided main clock (fXIN /128) or main clock. For the switching between main and sub clock, recommend the oscillator 4.194304MHz as a main and 32.768kHz as a sub. Because above main frequency is equal to 128 times of sub frequency. Generally main clock (fXIN) at WTCK=10B is not be used, it is just for test purpose in factory. In the Stop Mode, the main clock is stopped but sub clock is oscillation continuously for watch clock operation. Output timer interval can be selected and Watch Timer Interrupt is generated. LDM EI LDM IENL,#XXXX_X1XXB WTMR,#0100_1000B
WDCK[1:0]
WDCLR
0: Stop 1: Clear and start clear
WDOE[0DFH]
00 WTCK[1:0] 2Hz
01 4Hz
MUX 10 11 16Hz 8Hz
2-bit Binary Counter
R34/WDTO
to RESET CPU
0 overflow 1 enable WDEN
fSXIN fXIN /128 fXIN
00 01 10
0f W 1 enable WTEN
14-bit Binary Counter 16Hz 2Hz
WDTIF WDOM
Watchdog Timer Interrupt
When fSXIN = 32.768 kHz fXIN = 4.194304 MHz
10 01 00 Interval Selector MUX WTIN[1:0]
4Hz
WTIF
Watch Timer interrupt
Figure 19-1 Block Diagram of Watchdog Timer
19.2 Watchdog Timer
The watchdog timer rapidly detects the CPU malfunction such as endless looping caused by noise or the like, and resumes the CPU to the normal state. The watchdog timer signal for detecting malfunction can be selected either a reset CPU or a interrupt request as you want. When the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an interrupt at fixed intervals. The CPU malfunction is detected during setting of the detection time, selecting of output, and clearing of the binary counter. Clearing the 2-bit binary counter by bit WDCLR of WDTR is repeated within the detection time. If the malfunction occurs for any cause, the watchdog timer output will become active from the binary counters unless the binary counter is cleared. At this time, when WDOM=1, a reset is generated, which drives the RESET pin to low to reset the internal hardware. When WDOM=0, a watchdog timer interrupt (WDTIF) is generated instead of Reset function. This interrupt can be used general timer as user want. When main clock is selected as clock input source on the STOP mode, clock input is stopped so the watchdog timer temporarily stops counting. The other side, when sub clock is selected as clock input source on the STOP mode, sub clock operates always
Watchdog Timer Control
Figure 19-2 shows the watchdog timer control register WDTR (address 0DFH). The watchdog timer is automatically enabled initially and watchdog output to reset CPU but clock input source is disabled. To enable this function, you should write bit WTEN of WTMR (address 0EFH) set to "1".
78
APR., 2001 Ver 2.01
GMS81C7008/7016
so the watchdog timer works continuously.
-
R/W
WTEN
-
-
R/W
R/W
R/W
R/W ADDRESS: 0EFH INITIAL VALUE: -0--_0000B
WTMR
-
WTIN1 WTIN0 WTCK1 WTCK0
Watch Timer count enable 0: Disable 1: Enable
Clock source selection 00: Sub clock 01: Main clock (fXIN / 128) 10: Main clock (test purpose in factory) 11: Watch timer interrupt interval selection 00: 16Hz When 01: 4Hz fXIN = 4.19MHz 10: 2Hz fSXIN = 32.768kHz 11: -
-
-
R/W
W DOE
R/W
R/W
R/W
R/W
R/W ADDRESS: 0DFH INITIAL VALUE: --01_0010B Clear bit 0: Normal operation 1: Clear and starts counting Output Mode 0: Interrupt request 1: Reset CPU Watchdog timer interrupt interval selection 00: 2 sec. When 01: 1 sec. fXIN = 4.19MHz 10: 0.5 sec. fSXIN = 32.768kHz 11: 0.25 sec.
WDTR
-
W D E N W D C K 1 W D C K 0 W D O M W D C LR
R34/WDTO selection 0: R34 port 1: WDTO port Watchdog Timer count enable 0: Disable 1: Enable
Figure 19-2 WTMR, WDTR: Watch Timer and Watchdog Timer Data Register Example: Sets the watchdog timer detection time to 1 sec at 4.19MHz, 32.768kHz LDM LDM SET1 : : : : SET1 : : : : SET1 WTMR,#0100_1000B WDTR,#0001_0111B WDCLR ;Select sub clock as an input source ;Clear counter
Within 0.75 sec.
WDCLR
;Clear counter
Within 0.75 sec.
WDCLR
;Clear counter
Enable and Disable Watchdog
Watchdog timer is enabled by setting WDEN (bit 4 in CKCTLR) to "1". WDEN is initialized to "1" during reset and it should be clear to "0" disable. Example: Enables watchdog timer for Reset : LDM LDM : WTMR,#0100_XXXXB;WTEN 1 WDTR,#00X1_XX11B;WDEN 1 The watchdog timer is disabled by clearing either bit 4 (WDEN) of WDTR or bit 6 (WTEN) of WTMR. The watchdog timer is halted in STOP mode and restarts automatically after STOP mode is released.
Clearing 2-bit binary counter of the Watchdog timer
The watchdog timer count the clock source as 14-bit binary
APR., 2001 Ver 2.01
79
GMS81C7008/7016
counter which is free run can not be cleared. The watchdog timer has 2-bit binary counter. It is incremented by 14-bit binary counter match as shown in Figure 19-1. Interrupt request flag or Reset signal are generated by overflow 2-bit binary counter. During normal operation in the software, 2-bit binary counter
should be cleared by bit WDCLR of WDTR within watchdog timer overflow. The time of clearing must be within 3 times of 14-bit binary counter interval as shown in Figure 19-3. The worst case, watchdog time is just 3 times of 14-bit counter.
1FFE
1FFF 0 1 2
1FFE
1FFF 0 1 2
1FFE
1FFF 0 1 2
1FFE
1FFF 0 1 2
~ ~
~ ~
~ ~
14-bit binary counter 2-bit binary counter
~ ~
~ ~
~ ~
n
0
1
2
3
0 Counter Clear
WDTIF interrupt
R34/WDTO pin
(2us at fXIN=4.19MHz) 8 osc. Even if user set to 1 sec., worst case 0.75 second
reset
Write WDCLR = 1 at this point
When WDTR = 0011_0111B
Figure 19-3 Watchdog timer Timing If the watchdog timer output becomes active, a reset is generated, which drives the RESET pin low to reset the internal hardware. The main clock oscillator also turns on when a watchdog timer reset is generated in sub clock mode.
80
APR., 2001 Ver 2.01
GMS81C7008/7016
20. POWER DOWN OPERATION
The GMS81C7008/16 has two power-down modes. In powerdown mode, power consumption is reduced considerably that in Battery operation Battery life can be extended a lot.
Sleep mode is entered by setting bit 0 of Sleep Mode Register, and STOP Mode is entered by STOP instruction.
20.1 SLEEP Mode
In this mode, the internal oscillation circuits remain active. Oscillation continues and peripherals are operate normally but CPU stops. Movement of all Peripherals is shown in Table 20-1. Sleep mode is entered by setting bit 0 of SMR (address 0DEH). It is released by RESET or interrupt. To be release by interrupt, interrupt should be enabled before Sleep mode.
Sleep Mode Register SMR 0: Release Sleep Mode 1: Enter Sleep Mode ADDRESS : 0DEH RESET VALUE : -------0 W
Figure 20-1 SLEEP Mode Register
Oscillator (XIN or SXIN pin) Internal CPU Clock
~ ~ ~ ~
Interrupt
Set bit 0 of SMR Release
Normal Operation
Stand-by Mode
Normal Operation
Figure 20-2 Sleep Mode Release Timing by External Interrupt
.
Oscillator (XIN or SXIN pin)
~ ~
~ ~
Internal CPU Clock
~ ~
~~ ~~
RESET
Set bit 0 of SMR
Release
~~ ~~
~~ ~~
BIT Counter
0
1
2
FE
FF
0
1
2
Clear & Start
Normal Operation
Sleep Mode
tST = 62.5ms Normal Operation at 4.19MHz by hardware tST = 1 fMAIN /1024 x 256
Figure 20-3 SLEEP Mode Release Timing by RESET pin
APR., 2001 Ver 2.01
81
GMS81C7008/7016
20.2 STOP Mode
For applications where power consumption is a critical factor, device provides reduced power of STOP. Start The Stop Operation An instruction that STOP causes to be the last instruction is executed before going into the STOP mode. In the Stop
Peripheral CPU RAM LCD driver Basic Interval Timer Timer/Event counter Watch Timer Main-oscillation Sub-oscillation I/O ports Control Registers Release method STOP Mode All CPU operations are disabled Retain LCD driver operates continuously Halted Halted (Only when the Event counter mode is enabled, Timer operates normally) Watch Timer operates continuously Stop (XIN pin = "L", XOUT pin = "L") Oscillation Retain Retain RESET, Key Scan interrupt, SIO interrupt, Watch Timer interrupt, Timer interrupt (EC0,2), External interrupt
mode, the on-chip main-frequency oscillator is stopped. With the clock frozen, all functions are stopped, but the onchip RAM and Control registers are held. The port pins output the values held by their respective port data register, the port direction registers. The status of peripherals during Stop mode is shown below.
SLEEP Mode All CPU operations are disabled Retain LCD driver operates continuously BIT operates continuously Timer/Event counter operates continuously Watch Timer operates continuously Oscillation Oscillation Retain Retain RESET, All interrupts
Table 20-1 Peripheral Operation during Power Down Mode : The Interval Timer Register CKCTLR should be initialized (0FH or 0EH) by software in order that oscillation stabilization time should be longer than 20ms before STOP mode.
Note: Since the XIN pin is connected internally to GND to avoid current leakage due to the crystal oscillator in STOP mode, do not use STOP instruction when an external clock is used as the main system clock.
In the Stop mode of operation, VDD can be reduced to minimize power consumption. Be careful, however, that VDD is not reduced before the Stop mode is invoked, and that VDD is restored to its normal operating level before the Stop mode is terminated. The reset should not be activated before VDD is restored to its normal operating level, and must be held active long enough to allow the oscillator to restart and stabilize. And after STOP instruction, at least two or more NOP instruction should be written as shown in example below.
Release the STOP mode
The exit from STOP mode is using hardware reset or external interrupt, watch timer, key scan or timer/counter. To release STOP mode, corresponding interrupt should be enabled before STOP mode. Specially as a clock source of Timer/Event counter, EC0 or EC2 pin can release it by Timer/Event counterInterrupt request Reset redefines all the control registers but does not change the on-chip RAM. External interrupts allow both on-chip RAM and Control registers to retain their values. Start-up is performed to acquire the time for stabilizing oscillation. During the start-up, the internal operations are all stopped.
Example)
; LDM LDM STOP NOP NOP CKCTLR,#0EB ;32.8ms CKCTLR,#0FB ;65.5ms
82
APR., 2001 Ver 2.01
GMS81C7008/7016
Oscillator (XIN pin)
~~ ~~
~ ~ ~ ~
Internal Clock
~ ~
~ ~
External Interrupt
~ ~
STOP Instruction Executed
~~ ~~
~~ ~~
BIT Counter
n
n+1 n+2
n+3
0 Clear
1
FE
FF
0
1
2
Normal Operation
Stop Operation
tST > 20ms by software
Normal Operation
Before executing Stop instruction, Basic Interval Timer must be set properly by software to get stabilization time which is longer than 20ms.
Figure 20-4 STOP Mode Release Timing by External Interrupt
Oscillator (XIN pin)
~~ ~~
~ ~
Internal Clock
~ ~
~ ~ ~ ~
RESET BIT Counter
~ ~
STOP Instruction Executed n n+1 n+2 n+2 n+3
~~ ~~
Normal Operation
Stop Operation tST > 62.5ms at 4.19MHz by hardware 1 fMAIN /1024
Figure 20-5 STOP Mode Release Timing by RESET
~~ ~~
0 Clear
1
FE
FF
0
1
2
Normal Operation
tST =
x 256
Minimizing Current Consumption The Stop mode is designed to reduce power consumption. To minimize current drawn during Stop mode, the user should turn-off output drivers that are sourcing or sinking current, if it is practical.
Note: In the STOP operation, the power dissipation associated with the oscillator and the internal hardware is lowered; however, the power dissipation associated with the
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation of the STOP feature. This point should be little current flows when the input level is stable at the power voltage level (VDD/VSS); however, when the input level becomes higher than the power voltage level (by approximately 0.3V), a current begins to flow. Therefore, if cutting off the output transistor at an I/O port puts the pin signal into the highimpedance state, a current flow across the ports input transistor, requiring it to fix the level by pull-up or other means.
APR., 2001 Ver 2.01
83
GMS81C7008/7016
It should be set properly that current flow through port doesn't exist. First consider the setting to input mode. Be sure that there is no current flow after considering its relationship with external circuit. In input mode, the pin impedance viewing from external MCU is very high that the current doesn't flow. But input voltage level should be VSS or VDD. Be careful that if unspecified voltage, i.e. if un-firmed voltage level (not VSSor
VDD) is applied to input pin, there can be little current (max. 1mA at around 2V) flow. If it is not appropriate to set as an input mode, then set to output mode considering there is no current flow. Setting to High or Low is decided considering its relationship with external circuit. For example, if there is external pull-up resistor then it is set to output mode, i.e. to High, and if there is external pull-down register, it is set to low.
VDD INPUT PIN internal pull-up OPEN INPUT PIN VDD VDD i=0
VDD
O
O
i GND VDD
i
Very weak current flows
X
Weak pull-up current flows
X
OPEN
i=0
GND
O
O
When port is configure as an input, input level should be closed to 0V or 5V to avoid power consumption.
Figure 20-6 Application Example of Unused Input Port
OUTPUT PIN ON OPEN ON OFF i GND VDD ON OFF OFF
OUTPUT PIN VDD L ON OFF i GND ON i=0 GND L VDD
O
OFF
X
X O
O
In the left case, Tr. base current flows from port to GND. To avoid power consumption, there should be low output to the port .
In the left case, much current flows from port to GND.
Figure 20-7 Application Example of Unused Output Port
84
APR., 2001 Ver 2.01
GMS81C7008/7016
21. OSCILLATOR CIRCUIT
The GMS81C7008/16 has two oscillation circuits internally. XIN and XOUT are input and output for main frequency and SXIN and SXOUT are input and output for sub frequency, respectively, inverting amplifier which can be configured for being used as an on-chip oscillator, as shown in Figure 21-1. To use RC oscillation instead of crystal, user should check mark on the "A. MASK ORDER SHEET" on page i of the appendix of this manual. However in the OTP device, when the programming RC oscillation can be selected or not into the configuration bit. For more detail, refer to "24.1 OTP Programming" on page 89.
Note: When using the sub clock oscillation, connect a resistor in series with R which is shown as below figure. In order to reduce the power consumption, the sub clock oscillator employs a low amplification factor circuit. Because of this, the sub clock oscillator is more sensitive to noise than the main system clock oscillator.
C1 XOUT C2
C1 R C2 32.768kHz SXOUT
4.19MHz
XIN VSS
SXIN VSS
Recommend Crystal Oscillator Ceramic Resonator C1,C2 = 20pF C1,C2 = 30pF
Recommend C1,C2 = 30pF5pF R= 47k5k
Crystal or Ceramic Oscillator
Open
XOUT REXT
XOUT
External Clock
XIN
XIN
For selection R value, Refer to AC Characteristics
External Oscillator
RC Oscillator (mask option)
Figure 21-1 Oscillation Circuit Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Since each crystal and ceramic resonator have their own characteristics, the user should consult the crystal manufacturer for appropriate values of external components. Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Since each crystal and ceramic resonator have their own characteristics, the user should consult the crystal manufacturer for appropriate values of external components. In addition, see Figure 21-2 for the layout of the crystal.
XOUT XIN
Note: Minimize the wiring length. Do not allow the wiring to intersect with other signal conductors. Do not allow the wiring to come near changing high current. Set the potential of the grounding position of the oscillator capacitor to that of VSS. Do not ground it to any ground pattern where high current is present. Do not fetch signals from the oscillator.
Figure 21-2 Recommend Layout of Oscillator PCB circuit
APR., 2001 Ver 2.01
85
GMS81C7008/7016
22. RESET
The GMS81C7008/16 has two types of reset generation procedures; one is an external reset input, the other is a watch-dog timer reset. Table 22-1 shows on-chip hardware initialization by reset action.
VCC
On-chip Hardware Program counter (PC) G-flag (G) Operation mode Peripheral clock
Initial Value (FFFFH) - (FFFEH) 0 Main operating mode On Disable (Because the Watch timer is disabled) Refer to Table 8-1 on page 25 Enable
10k 7036P
+
Watchdog timer
to the RESET pin
10uF
Control registers Low voltage detector
Table 22-1 Initializing Internal Status by Reset Action Figure 22-1 Simple Power-on-Reset Circuit.
22.1 External Reset Input
The reset input is the RESET pin, which is the input to a Schmitt Trigger. A reset in accomplished by holding the RESET pin low for at least 8 oscillator periods, within the operating voltage range and oscillation stable, it is applied, and the internal state is initialized. After reset, 64ms (at 4 MHz) add with 7 oscillator periods are required to start execution as shown in Figure 22-2. Internal RAM is not affected by reset. When VDD is turned on, the RAM content is indeterminate. Therefore, this RAM should
1 2 3 4 5 6 7
be initialized before read or tested it. When the RESET pin input goes to high, the reset operation is released and the program execution starts at the vector address stored at addresses FFFEH - FFFFH. A connection for simple power-on-reset is shown in Figure .
~ ~
Oscillator (XIN pin) RESET
~ ~ ~ ~
ADDRESS BUS DATA BUS
?
?
?
?
FFFE FFFF Start
~~ ~~
?
?
?
?
FE
ADL
ADH
OP
Stabilization Time tST = 62.5mS at 4.19MHz
Figure 22-2 Timing Diagram after RESET
~ ~
RESET Process Step 1 fMAIN /1024 MAIN PROGRAM tST = x 256
22.2 Watchdog Timer Reset
Refer to "18. LCD DRIVER" on page 70.
86
APR., 2001 Ver 2.01
GMS81C7008/7016
23. POWER FAIL PROCESSOR
The GMS81C7008/16 has an on-chip low voltage detection circuitry to detect the VDD voltage. A configuration register, LVDR (address 0FBH), can enable or disable the low voltage detect circuitry. Whenever VDD falls close to or below 2.2V, the LVD0 is just set to "1", and if it recovering 3.4V, LVD0 is held to "1". If VDD falls below around 3.4V range, the low voltage situation may reset the MCU or freeze the clock according to setting of bit 5 (LVDM) of LVDR . The bit 4 LVD1 function is same with LVD0 except different voltage level 2.1V. The detection voltage is varied very little. See "7.3 DC Electrical Characteristics" on page 11 for more detail voltage level. In the in-circuit emulator, power fail function is not implemented and user may not use it. Therefore, after completed development of user program, this function may be experimented or evaluated using by OTP. When power fail certainly occur the MCU was reset, program notify this Reset circumstance cause by LVD function. So, does not erase the all RAM contents and operates subsequently as shown in Figure .
ADDRESS: 0FBH INITIAL VALUE: 00H 3
LVD0
R/W 7
R/W 6
LVDS
R/W 5
LVDM
R/W 4
LVD1
2
1
0
LVDR
LVDE
VDD Detection Flag 1 0: Above 3.4V 1: Below 3.4V VDD Detection Flag 2 0: Above 2.1V 1: Below 2.1V Operation Mode 0: Clock freeze 1: Reset Power Fail Voltage Selection 0: 3.4V 1: 2.1V Enable / Disable Flag 0: Disable 1: Enable
Figure 23-1 Low Voltage Detector Register
RESET VECTOR
LVD0 =1 NO RAM CLEAR INITIALIZE RAM DATA
YES
Skip the initial routine when the Reset cause from power fail.
INITIALIZE ALL PORTS INITIALIZE REGISTERS
FUNTION EXECUTION
Figure 23-2 Example S/W of RESET by Power fail
APR., 2001 Ver 2.01
87
GMS81C7008/7016
VDD Internal RESET VDD When LVDM = 1 Internal RESET VDD Internal RESET 64mS t <64mS 64mS 64mS
LVDVDDMAX LVDVDDMIN
LVDVDDMAX LVDVDDMIN
LVDVDDMAX LVDVDDMIN
Figure 23-3 Power Fail Processor Situations
88
APR., 2001 Ver 2.01
GMS81C7008/7016
24. DEVELOPMENT TOOLS
24.1 OTP Programming
The GMS87C7016 is OTP (One Time Programmable) type microcontrollers. Its internal user memory is constructed with EPROM (Electrically Programmable Read Only Memory). The OTP microcontroller is generally used for chip evaluation, first production, small amount production, fast mass production, etc. Blank OTP's internal EPROM is filled by 00H, not FFH. The CHOICE-SIGMA is a HEI Universal Single Programmer for all of HEI OTP devices, also the CHOICE-GANG4 can program four OTPs at once.
Programming Procedure 1. Select device GMS87C7016 as you want. 2. Load the *.OTP file from the PC to Programmer. The file is composed of Motorola-S1 format. 3. Set the programming address range as below table. 4. Mount the socket adapter on the programmer. 5. Set the configuration bytes as your needs. 6. Start program/verify. Select the option for Program Lock and RC oscillation
Note: In any case, you have to use the *.OTP file for programming, not the *.HEX file. After assemble the source program, both OTP and HEX file are generated by automatically. The HEX file is used during program emulation on the emulator.
87C70XX-64SD
87C71XX-52SD
Except the user program memory C000H~FFFFH, there is configuration byte (address 707FH) for the selection of program lock and RC oscillation. The configuration byte of OTP is shown as Figure 24-1. It could be served when user use the OTP programmer (Choice-Sigma or Choice-Gang4).
OTP Configuration Byte
87C70XX-64QF 7 6 5 4 3
ADDRESS: 707FH 2
LOCK
1
RC
0
How to Program
To program the OTP devices, user should use HEI own programmer. Ask to HEI sales part for purchasing or more detail. Programmer: CHOICE-SIGMA (Single type) CHOICE-GNAG4 (4-gang type) Socket adapter:87C70XX-64SD (for 64SDIP) 87C70XX-64QF (for 64MQFP)
Oscillation Option 0: Crystal or Resonator 1: External RC Oscillator Lock bit 0: Allow code read out 1: Not allow code read out
Figure 24-1 The OTP Configuration Byte
APR., 2001 Ver 2.01
89
-B86(5%
6(*79 6(*77 6(*75 6(*73 6(*6; 95(* &2042669 &2062667 6(*65 6(*63 6(*5; 6(*59 6(*57 6(*55 6(*53 6(*4; 6(*49 6(*47 6(*45 6(*43 6(*; 6(*9 6(*7 6(*5 6(*3
-B86(5$
*1' 6(*7: 9&/3 6(*78 9&/5 6(*76 &$ 6(*74 *1' 6(*6< 28B567 6(*6: 8B;287 &203 *1' &2052668 56: 6(*66 568 6(*64 553 6(*5< 555 6(*5: 557 6(*58 559 6(*56 54: 6(*54 548 6(*4< 546 6(*4: 544 6(*48 53: 6(*46 538 6(*44 536 6(*< 534 6(*: 566 6(*8 564 6(*6 .89 6(*4 *1' 9&/4 9/&'& &% *1' 11&1 5(0287 +721(', *1' 569 567 554 556 558 55: 549 547 545 543 539 537 535 533 565 563 .89
CHOICE-Dr. EVA 81C51/81C7x B/D Rev 1.1 S/N. ---------------
1 2 3 4 5 6 7 8
SW4
1 2
SW5
/&'B9GG
581 6723 6/((3
24.2 Emulator EVA. Board Setting
VR1
32:(5
SW2
External oscillator SW1 socket +5V
;287 ON
OFF
-B86(5% -B86(5$
;4#+26&,
9B86(5
GMS81C7008/7016
6XSSO\#.89#+PD[1#533P$,
21
5(6(7
;5
9/&'&
OFF
ON
25(6(7
90
APR., 2001 Ver 2.01
GMS81C7008/7016
DIP Switch and VR Setting
Before execute the user program, keep in your mind the below configuration DIP S/W, VR SW1 Description Emulator Reset Switch. Reset the Emulator. ON/OFF Setting Reset the Emulator. Normally OFF. EVA. chip can be reset by external user target board. ON : Reset is available by either user target system board or Emulator RESET switch. OFF : Reset the MCU by Emulator RESET switch. Does not work from user target board. Normally OFF. MCU XOUT pin is disconnected internally in the Emulator. Some circumstance user may connect this circuit. ON : Output XOUT signal OFF : Disconnect circuit
SW2-1
1
EVA. Chip
RESET pin
Pod RESET pin configuration SW2
SW2-2 XOUT pin
2
EVA. Chip Oscillator
Pod XOUT pin configuration External Bias Resistors Connection
EVA. Chip Internal
BIAS
VDD
SW4
SW4-1
Adjust Contrast VR1 50k
VCL2
1 2 3
SW4-2
VCL1
10k x 3 SW4-3
VCL0
Must be ON position. It serves the external bias resistors. If this switches are turned off, LCD bias voltage does not supplied, floated because there are no internal bias resistors and bias Tr. inside the Emulator.
0.47uF x 3
VSS
External Resistor and Capacitor
SW4
4 5 6
LCD Voltage doubling circuit.
Must be OFF position. It is reserved for the GMS81C5108. Must be ON position. This switch select the Stack page 0 (off) or page 1 (on). ON : For the 81C7XXX OFF : For the GMS81C5108
VDD
7
Select the Stack Page.
EVA. Chip
LVD pin
SW4-8
8 81Cx detect the VDD voltage but Emulator can not do because Emulator can not operate if VDD is below normal opr. voltage (5V), This switch serves LVD environment through the applying 0V to LVD pin of EVA. chip during 5V normal operation.
Position ON during normal operation. ON : Normal operation OFF : Force to detect the LVD, refer to "23. POWER FAIL PROCESSOR" on page 87.
APR., 2001 Ver 2.01
91
GMS81C7008/7016
DIP S/W, VR SW5 1 2
Description Internal power supply to sub-oscillation circuit. Reserved for other purpose. Adjust the LCD contrast. It supply bias voltage and adjust the VCL2 voltage.
EVA. Chip Internal
BIAS
ON/OFF Setting Must be ON position. Must be OFF position.
VDD
Adjust Contrast
VR1 50k
SW4-1
VCL2
VR1
-
SW4-2
VCL1
10k x 3 SW4-3
Adjust the proper position as well as LCD display good.
VCL0
0.47uF x 3
VSS
External Resistor and Capacitor
VR2
-
Reserved for other purpose.
Don't care.
92
APR., 2001 Ver 2.01
APPENDIX
A. MASK ORDER SHEET
MASK ORDER & VERIFICATION SHEET
GMS81C7008 GMS81C7016 -LA
Customer should write inside thick line box. 1. Customer Information Company Name Application
YYYY MM DD
2. Device Information Package ROM Size
R C O SC O pt.
64SDIP 8K Crystal
64MQFP 16K RC .OTP) )
GMS81C7016 (16K ROM) GMS81C7008 (8K ROM)
Order Date Tel: E-mail: Name & Signature: 3. Marking Specification
08 or 16
Fax:
Mask Data File Name: ( Check Sum: ( Internet
.OTP file data C000H
DFFFH E000H
(Please check mark into
)
FFFFH
Customer's logo
GMS81C70 YYWW
-LA
Hynix ROM Code Number
KOREA
-LA GMS81C70 YYWW KOREA
Customer logo is not required. If the customer logo must be used in the special mark, please submit a clean original of the logo. Customer's part number
Lot Number
4. Delivery Schedule Date
YYYY MM DD
Quantity pcs
Hynix Confirmation
Customer Sample
YYYY MM DD
Risk Order 5. ROM Code Verification
YYYY MM DD
pcs This box is written after "5.Verification". Approval Date:
YYYY MM DD
Verification D ate:
Please confirm our verification data.
I agree with your verification data and confirm you to m ake m ask set.
Check Sum: Tel: E-mail: Name & Signature:
01-APR-2001
Tel: Fax: Name & Signature:
Fax:
GMS81C71XX LCD MCU APPENDIX
B. INSTRUCTION
B.1 Terminology List
Terminology A X Y PSW #imm dp !abs [] {} { }+ .bit A.bit dp.bit M.bit rel upage n + x Accumulator X - register Y - register Program Status Word 8-bit Immediate data Direct Page Offset Address Absolute Address Indirect expression Register Indirect expression Register Indirect expression, after that, Register auto-increment Bit Position Bit Position of Accumulator Bit Position of Direct Page Memory Bit Position of Memory Data (000H~0FFFH) Relative Addressing Data U-page (0FF00H~0FFFFH) Offset Address Table CALL Number (0~15) Addition
0 Bit Position
Description
Upper Nibble Expression in Opcode
y - x / ()
1 Bit Position
Upper Nibble Expression in Opcode
Subtraction Multiplication Division Contents Expression AND OR Exclusive OR NOT Assignment / Transfer / Shift Left Shift Right Exchange Equal Not Equal
~ =
APR. 2001 Ver 2.01
ii
GMS81C71XX LCD MCU APPENDIX
B.2 Instruction Map
LOW 00000 HIGH
00 -
00001 01 SET1 dp.bit
00010 02
00011 03
00100 04 ADC #imm SBC #imm CMP #imm OR #imm AND #imm EOR #imm LDA #imm LDM dp,#imm
00101 05 ADC dp SBC dp CMP dp OR dp AND dp EOR dp LDA dp STA dp
00110 06 ADC dp+X SBC dp+X CMP dp+X OR dp+X AND dp+X EOR dp+X LDA dp+X STA dp+X
00111 07 ADC !abs SBC !abs CMP !abs OR !abs AND !abs EOR !abs LDA !abs STA !abs
01000 08 ASL A ROL A LSR A ROR A INC A DEC A TXA
01001 09 ASL dp ROL dp LSR dp ROR dp INC dp DEC dp LDY dp STY dp
01010 0A
01011 0B
01100 0C BIT dp COM dp TST dp CMPX dp CMPY dp DBNE dp LDX dp STX dp
01101 0D POP A POP X POP Y POP PSW CBNE dp+X XMA dp+X LDX dp+Y STX dp+Y
01110 0E PUSH A PUSH X PUSH Y PUSH PSW TXSP
01111 0F BRK BRA rel PCALL Upage RET INC X DEC X DAS
000
BBS BBS A.bit,rel dp.bit,rel
TCALL SETA1 0 .bit TCALL CLRA1 2 .bit TCALL 4 TCALL 6 NOT1 M.bit OR1 OR1B
001
CLRC
010
CLRG
011
DI
100
CLRV
TCALL AND1 8 AND1B TCALL EOR1 10 EOR1B TCALL 12 TCALL 14 LDC LDCB STC M.bit
101
SETC
TSPX
110
SETG
XCN
111
EI
TAX
XAX
STOP
LOW 10000 HIGH
10 BPL rel BVC rel BCC rel BNE rel BMI rel BVS rel BCS rel BEQ rel
10001 11 CLR1
dp.bit
10010 12 BBC
A.bit,rel
10011 13 BBC
dp.bit,rel
10100 14 ADC {X} SBC {X} CMP {X} OR {X} AND {X} EOR {X} LDA {X} STA {X}
10101 15 ADC !abs+Y SBC !abs+Y CMP !abs+Y OR !abs+Y AND !abs+Y EOR !abs+Y LDA !abs+Y STA !abs+Y
10110 16 ADC [dp+X] SBC [dp+X] CMP [dp+X] OR [dp+X] AND [dp+X] EOR [dp+X] LDA [dp+X] STA [dp+X]
10111 17 ADC [dp]+Y SBC [dp]+Y CMP [dp]+Y OR [dp]+Y AND [dp]+Y EOR [dp]+Y LDA [dp]+Y STA [dp]+Y
11000 18 ASL !abs ROL !abs LSR !abs ROR !abs INC !abs DEC !abs LDY !abs STY !abs
11001 19 ASL dp+X ROL dp+X LSR dp+X ROR dp+X INC dp+X DEC dp+X LDY dp+X STY dp+X
11010 1A TCALL 1 TCALL 3 TCALL 5 TCALL 7 TCALL 9 TCALL 11 TCALL 13 TCALL 15
11011 1B JMP !abs CALL !abs MUL DBNE Y DIV XMA {X} LDA {X}+ STA {X}+
11100 1C BIT !abs TEST !abs
11101 1D ADDW dp SUBW dp
11110 1E LDX #imm LDY #imm CMPX #imm CMPY #imm INC Y DEC Y XAY
11111 1F JMP [!abs] JMP [dp] CALL [dp] RETI
000
001
010
TCLR1 CMPW !abs dp CMPX !abs CMPY !abs XMA dp LDX !abs STX !abs LDYA dp INCW dp DECW dp STYA dp CBNE dp
011
100
TAY
101
TYA
110
DAA
111
XYX
NOP
iii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
B.3 Instruction Set
Arithmetic / Logic Operation
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Mnemonic
ADC #imm ADC dp ADC dp + X ADC !abs ADC !abs + Y ADC [ dp + X ] ADC [ dp ] + Y ADC { X } AND #imm AND dp AND dp + X AND !abs AND !abs + Y AND [ dp + X ] AND [ dp ] + Y AND { X } ASL A ASL dp ASL dp + X ASL !abs CMP #imm CMP dp CMP dp + X CMP !abs CMP !abs + Y CMP [ dp + X ] CMP [ dp ] + Y CMP { X } CMPX #imm CMPX dp CMPX !abs CMPY #imm CMPY dp CMPY !abs COM dp DAA DAS DEC A DEC dp DEC dp + X DEC !abs DEC X DEC Y
Op Code
04 05 06 07 15 16 17 14 84 85 86 87 95 96 97 94 08 09 19 18 44 45 46 47 55 56 57 54 5E 6C 7C 7E 8C 9C 2C DF CF A8 A9 B9 B8 AF BE
Byte No
2 2 2 3 3 2 2 1 2 2 2 3 3 2 2 1 1 2 2 3 2 2 2 3 3 2 2 1 2 2 3 2 2 3 2 1 1 1 2 2 3 1 1
Cycle No
2 3 4 4 5 6 6 3 2 3 4 4 5 6 6 3 2 4 5 5 2 3 4 4 5 6 6 3 2 3 4 2 3 4 4 3 3 2 4 5 5 2 2 Arithmetic shift left
C
Operation
Add with carry. A(A)+(M)+C
Flag
NVGBHIZC
NV--H-ZC
Logical AND A (A)(M) N-----Z-
76543210
N-----ZC
"0"
Compare accumulator contents with memory contents (A) -(M)
N-----ZC
Compare X contents with memory contents (X)-(M) Compare Y contents with memory contents (Y)-(M) 1'S Complement : ( dp ) ~( dp ) Decimal adjust for addition Decimal adjust for subtraction Decrement M (M)-1 N-----ZC N-----ZC
N-----ZN-----ZC N-----ZC N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z-
APR. 2001 Ver 2.01
iv
GMS81C71XX LCD MCU APPENDIX
No.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 DIV
Mnemonic
Op Code
9B A4 A5 A6 A7 B5 B6 B7 B4 88 89 99 98 8F 9E 48 49 59 58 5B 64 65 66 67 75 76 77 74 28 29 39 38 68 69 79 78 24 25 26 27 35 36 37 34 4C CE
Byte No
1 2 2 2 3 3 2 2 1 1 2 2 3 1 1 1 2 2 3 1 2 2 2 3 3 2 2 1 1 2 2 3 1 2 2 3 2 2 2 3 3 2 2 1 2 1
Cycle No
12 2 3 4 4 5 6 6 3 2 4 5 5 2 2 2 4 5 5 9 2 3 4 4 5 6 6 3 2 4 5 5 2 4 5 5 2 3 4 4 5 6 6 3 3 5 Subtract with Carry Logical shift right Increment M (M)+1 Exclusive OR A (A)(M)
Operation
Divide : YA / X Q: A, R: Y
Flag
NVGBHIZC NV--H-Z-
EOR #imm EOR dp EOR dp + X EOR !abs EOR !abs + Y EOR [ dp + X ] EOR [ dp ] + Y EOR { X } INC A INC dp INC dp + X INC !abs INC X INC Y LSR A LSR dp LSR dp + X LSR !abs MUL OR #imm OR dp OR dp + X OR !abs OR !abs + Y OR [ dp + X ] OR [ dp ] + Y OR { X } ROL A ROL dp ROL dp + X ROL !abs ROR A ROR dp ROR dp + X ROR !abs SBC #imm SBC dp SBC dp + X SBC !abs SBC !abs + Y SBC [ dp + X ] SBC [ dp ] + Y SBC { X } TST dp XCN
N-----Z-
N-----ZC N-----ZN-----ZN-----ZN-----ZN-----Z-
76543210 C "0"
N-----ZC
Multiply : YA Y x A Logical OR A (A)(M)
N-----Z-
N-----Z-
Rotate left through Carry
C 76543210
N-----ZC
Rotate right through Carry
76543210 C
N-----ZC
A ( A ) - ( M ) - ~( C ) NV--HZC
Test memory contents for negative or zero, ( dp ) - 00H Exchange nibbles within the accumulator A7~A4 A3~A0
N-----ZN-----Z-
v
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
Register / Memory Operation
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
Mnemonic
LDA #imm LDA dp LDA dp + X LDA !abs LDA !abs + Y LDA [ dp + X ] LDA [ dp ] + Y LDA { X } LDA { X }+ LDM dp,#imm LDX #imm LDX dp LDX dp + Y LDX !abs LDY #imm LDY dp LDY dp + X LDY !abs STA dp STA dp + X STA !abs STA !abs + Y STA [ dp + X ] STA [ dp ] + Y STA { X } STA { X }+ STX dp STX dp + Y STX !abs STY dp STY dp + X STY !abs TAX TAY TSPX TXA TXSP TYA XAX XAY XMA dp XMA dp+X XMA {X} XYX
Op Code
C4 C5 C6 C7 D5 D6 D7 D4 DB E4 1E CC CD DC 3E C9 D9 D8 E5 E6 E7 F5 F6 F7 F4 FB EC ED FC E9 F9 F8 E8 9F AE C8 8E BF EE DE BC AD BB FE
Byte No
2 2 2 3 3 2 2 1 1 3 2 2 2 3 2 2 2 3 2 2 3 3 2 2 1 1 2 2 3 2 2 3 1 1 1 1 1 1 1 1 2 2 1 1
Cycle No
2 3 4 4 5 6 6 3 4 5 2 3 4 4 2 3 4 4 4 5 5 6 7 7 4 4 4 5 5 4 5 5 2 2 2 2 2 2 4 4 5 6 5 4 Load Y-register Y(M) Load accumulator A(M)
Operation
Flag
NVGBHIZC
N-----Z-
X- register auto-increment : A ( M ) , X X + 1 Load memory with immediate data : ( M ) imm Load X-register X (M) N-----Z--------
N-----Z-
Store accumulator contents in memory (M)A --------
X- register auto-increment : ( M ) A, X X + 1 Store X-register contents in memory (M) X Store Y-register contents in memory (M) Y Transfer accumulator contents to X-register : X A Transfer accumulator contents to Y-register : Y A Transfer stack-pointer contents to X-register : X sp Transfer X-register contents to accumulator: A X Transfer X-register contents to stack-pointer: sp X Transfer Y-register contents to accumulator: A Y Exchange X-register contents with accumulator :X A Exchange Y-register contents with accumulator :Y A Exchange memory contents with accumulator (M)A Exchange X-register contents with Y-register : X Y N-----Z----------------------
N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z---------------
APR. 2001 Ver 2.01
vi
GMS81C71XX LCD MCU APPENDIX
16-BIT operation
No.
1 2 3 4 5 6 7
Mnemonic
ADDW dp CMPW dp DECW dp INCW dp LDYA dp STYA dp SUBW dp
Op Code
1D 5D BD 9D 7D DD 3D
Byte No
2 2 2 2 2 2 2
Cycle No
5 4 6 6 5 5 5
Operation
16-Bits add without Carry YA ( YA ) ( dp +1 ) ( dp ) Compare YA contents with memory pair contents : (YA) - (dp+1)(dp) Decrement memory pair ( dp+1)( dp) ( dp+1) ( dp) - 1 Increment memory pair ( dp+1) ( dp) ( dp+1) ( dp ) + 1 Load YA YA ( dp +1 ) ( dp ) Store YA ( dp +1 ) ( dp ) YA 16-Bits subtract without carry YA ( YA ) - ( dp +1) ( dp)
Flag
NVGBHIZC NV--H-ZC N-----ZC N-----ZN-----ZN-----Z-------NV--H-ZC
Bit Manipulation
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Mnemonic
AND1 M.bit AND1B M.bit BIT dp BIT !abs CLR1 dp.bit CLRA1 A.bit CLRC CLRG CLRV EOR1 M.bit EOR1B M.bit LDC M.bit LDCB M.bit NOT1 M.bit OR1 M.bit OR1B M.bit SET1 dp.bit SETA1 A.bit SETC SETG STC M.bit TCLR1 !abs TSET1 !abs
Op Code
8B 8B 0C 1C y1 2B 20 40 80 AB AB CB CB 4B 6B 6B x1 0B A0 C0 EB 5C 3C
Byte No
3 3 2 3 2 2 1 1 1 3 3 3 3 3 3 3 2 2 1 1 3 3 3
Cycle No
4 4 4 5 4 2 2 2 2 5 5 4 4 5 5 5 4 2 2 2 6 6 6
Operation
Bit AND C-flag : C ( C ) ( M .bit ) Bit AND C-flag and NOT : C ( C ) ~( M .bit ) Bit test A with memory : Z ( A ) ( M ) , N ( M 7 ) , V ( M6 ) Clear bit : ( M.bit ) "0" Clear A bit : ( A.bit ) "0" Clear C-flag : C "0" Clear G-flag : G "0" Clear V-flag : V "0" Bit exclusive-OR C-flag : C ( C ) ( M .bit ) Bit exclusive-OR C-flag and NOT : C ( C ) ~(M .bit) Load C-flag : C ( M .bit ) Load C-flag with NOT : C ~( M .bit ) Bit complement : ( M .bit ) ~( M .bit ) Bit OR C-flag : C ( C ) ( M .bit ) Bit OR C-flag and NOT : C ( C ) ~( M .bit ) Set bit : ( M.bit ) "1" Set A bit : ( A.bit ) "1" Set C-flag : C "1" Set G-flag : G "1" Store C-flag : ( M .bit ) C Test and clear bits with A : A - ( M ) , ( M ) ( M ) ~( A ) Test and set bits with A : A-(M), (M) (M)(A)
Flag
NVGBHIZC -------C -------C MM----Z-
---------------------0 --0-----0--0---------C -------C -------C -------C --------------C -------C ---------------------1 --1-----------N-----ZN-----Z-
vii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
Branch / Jump Operation
No.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Mnemonic
BBC A.bit,rel BBC dp.bit,rel BBS A.bit,rel BBS dp.bit,rel BCC rel BCS rel BEQ rel BMI rel BNE rel BPL rel BRA rel BVC rel BVS rel CALL !abs CALL [dp] CBNE dp,rel CBNE dp+X,rel DBNE dp,rel DBNE Y,rel JMP !abs JMP [!abs] JMP [dp] PCALL upage
Op Code
y2 y3 x2 x3 50 D0 F0 90 70 10 2F 30 B0 3B 5F FD 8D AC 7B 1B 1F 3F 4F
Byte No
2 3 2 3 2 2 2 2 2 2 2 2 2 3 2 3 3 3 2 3 3 2 2
Cycle No
4/6 5/7 4/6 5/7 2/4 2/4 2/4 2/4 2/4 2/4 4 2/4 2/4 8 8 5/7 6/8 5/7 4/6 3 5 4 6 Branch if bit clear :
Operation
if ( bit ) = 0 , then pc ( pc ) + rel Branch if bit set : if ( bit ) = 1 , then pc ( pc ) + rel Branch if carry bit clear if ( C ) = 0 , then pc ( pc ) + rel Branch if carry bit set if ( C ) = 1 , then pc ( pc ) + rel Branch if equal if ( Z ) = 1 , then pc ( pc ) + rel Branch if minus if ( N ) = 1 , then pc ( pc ) + rel Branch if not equal if ( Z ) = 0 , then pc ( pc ) + rel Branch if plus if ( N ) = 0 , then pc ( pc ) + rel Branch always pc ( pc ) + rel Branch if overflow bit clear if (V) = 0 , then pc ( pc) + rel Branch if overflow bit set if (V) = 1 , then pc ( pc ) + rel Subroutine call M( sp)( pcH ), spsp - 1, M(sp) (pcL), sp sp - 1, if !abs, pc abs ; if [dp], pcL ( dp ), pcH ( dp+1 ) . Compare and branch if not equal : if ( A ) ( M ) , then pc ( pc ) + rel. Decrement and branch if not equal : if ( M ) 0 , then pc ( pc ) + rel. Unconditional jump pc jump address U-page call M(sp) ( pcH ), sp sp - 1, M(sp) ( pcL ), sp sp - 1, pcL ( upage ), pcH "0FFH" . Table call : (sp) ( pcH ), sp sp - 1, M(sp) ( pcL ),sp sp - 1, pcL (Table vector L), pcH (Table vector H)
Flag
NVGBHIZC ---------------
----------------------------------------------------------------
---------------
--------
--------
--------
24
TCALL n
nA
1
8
--------
APR. 2001 Ver 2.01
viii
GMS81C71XX LCD MCU APPENDIX
Control Operation & Etc.
No.
1 2 3 4 5 6 7 8 9 10 11 12 13
Mnemonic
BRK DI EI NOP POP A POP X POP Y POP PSW PUSH A PUSH X PUSH Y PUSH PSW RET
Op Code
0F 60 E0 FF 0D 2D 4D 6D 0E 2E 4E 6E 6F
Byte No
1 1 1 1 1 1 1 1 1 1 1 1 1
Cycle No
8 3 3 2 4 4 4 4 4 4 4 4 5
Operation
Software interrupt : B "1", M(sp) (pcH), sp sp-1, M(s) (pcL), sp sp - 1, M(sp) (PSW), sp sp -1, pcL ( 0FFDE H ) , pcH ( 0FFDFH) . Disable all interrupts : I "0" Enable all interrupt : I "1" No operation sp sp + 1, A M( sp ) sp sp + 1, X M( sp ) sp sp + 1, Y M( sp ) sp sp + 1, PSW M( sp ) M( sp ) A , sp sp - 1 M( sp ) X , sp sp - 1 M( sp ) Y , sp sp - 1 M( sp ) PSW , sp sp - 1 Return from subroutine sp sp +1, pcL M( sp ), sp sp +1, pcH M( sp ) Return from interrupt sp sp +1, PSW M( sp ), sp sp + 1, pcL M( sp ), sp sp + 1, pcH M( sp ) Stop mode ( halt CPU, stop oscillator )
Flag
NVGBHIZC ---1-0------0------1---------
-------restored
--------
--------
14 15
RETI STOP
7F EF
1 1
6 3
restored --------
ix
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
C. SOFTWARE EXAMPLE
;***************************************************************************** ; Title: GMS81C7016 (GMS800 Series) Demonstration Program * ; Company: Hynix semiconductor Inc. * ; Contents: LCD DISPLAY & DUAL THERMOMETER * ;***************************************************************************** ; ;******** DEFINE I/O PORT & FUNCTION REGISTER ADDRESS ********* ; R0 EQU 0C0H ;port R0 register R1 EQU 0C1H ;port R1 register R2 EQU 0C2H ;port R2 register R3 EQU 0C3H ;port R3 register R4 EQU 0C4H ;port R4 register R5 EQU 0C5H ;port R5 register ; R0DD EQU 0C8H ;port R0 data I/O direction register R1DD EQU 0C9H ;port R1 data I/O direction register R2DD EQU 0CAH ;port R2 data I/O direction register R3DD EQU 0CBH ;port R3 data I/O direction register R4DD EQU 0CCH ;port R4 data I/O direction register R5DD EQU 0CDH ;port R5 data I/O direction register ; R0PU EQU 0D0H ;port R0 Pull-up selection register R1PU EQU 0D1H ;port R1 Pull-up selection register R2PU EQU 0D2H ;port R2 Pull-up selection register R3PU EQU 0D3H ;port R3 Pull-up selection register ; R0CR EQU 0D4H ;port R0 Type selection register R1CR EQU 0D5H ;port R1 Type selection register R2CR EQU 0D6H ;port R2 Type selection register R3CR EQU 0D7H ;port R3 Type selection register ; IEDS EQU 0D8H ;External interrupt edge selection register PMR EQU 0D9H ;Alternative port mode register IENL EQU 0DAH ;int. enable register low IENH EQU 0DBH ;int. enable register high IRQL EQU 0DCH ;int. request flag register low IRQH EQU 0DDH ;int. request flag register high SLPR WDTR TM0 TDR0 TM1 TDR1 T1PPR T1PDR PWM0HR TM2 TDR2 TM3 TDR3 T3PPR T3PDR PWM1HR ADCM ADR WTMR KSMR LCDM LCDPM RPR BITR CKCTLR SCMR PFDR EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU 0DEH 0DFH 0E0H 0E1H 0E2H 0E3H 0E3H 0E4H 0E5H 0E6H 0E7H 0E8H 0E9H 0E9H 0EAH 0EBH 0ECH 0EDH 0EFH 0F0H 0F1H 0F2H 0F3H 0F4H 0F4H 0F5H 0FBH ;sleep mode register ;Watchdog timer register ;Timer 0 mode register ;Timer 0 data register ;Timer 1 mode register ;Timer 1 data register ;PWM0 period register ;Timer 1 pulse duty register ;PWM0 high register ;Timer 2 mode register ;Timer 2 data register ;Timer 3 mode register ;Timer 3 data register ;PWM1 period register ;Timer 3 pulse duty register ;PWM1 high register ;ADC mode register ;ADC result data register ;Watch timer mode register ;Key scan mode register ;LCD mode register ;LCD port mode register ;RAM paging register ;Basic interval timer data register ;Clock control register ;System clock mode register ;Power fail detector ;buzzer data register ;Serial mode register ;Serial data buffer register ************ ;Save Registers to Stacks
BUR EQU 0FDH SMR EQU 0FEH SIOD EQU 0FFH ; ;*********** MACRO DEFINITION ; R_SAVEMACRO
APR. 2001 Ver 2.01
x
GMS81C71XX LCD MCU APPENDIX
PUSH
X PUSH ENDM ; R_RSTRMACRO ;Restore Register from Stacks POP Y POP X POP A ENDM ; ;*********** CONSTANT DEFINITION *********** ; ; ; ;************************************************************************** ; RAM ALLOCATION * ;************************************************************************** TEMP0 DS 1 TEMP1 DS 1 TEMP2 DS 1 FLAG1 DS 1 RPTEN KEYONF ACTKEY TOGMO3 DUAL_T OUTSIDE FLAG2 F200MS F20MS F_1MIN LPM RPM STATUS RPTKEY F_CLOCK F_ON DISPSIGN DISPRAM DISPRAM1 ONDO LHOUR LMINUTE RHOUR RMINUTE TIMESET TSFLAG TSLPM TSRPM BLINKCNT ; NEWKY OLDKY PORTDT KEYNM KEYDT TOTLKY CHATFL R0BUF DGTCNT MODE SUBMODE BSCTIME TEMPCNT HZCNT EQU EQU EQU EQU EQU EQU DS EQU EQU EQU EQU EQU DS EQU EQU EQU DS DS DS DS DS DS DS DS DS DS EQU EQU DS DS DS DS DS DS DS DS DS DS DS DS DS DS DS 1,FLAG1 2,FLAG1 3,FLAG1 4,FLAG1 5,FLAG1 6,FLAG1 1 0,FLAG2 1,FLAG2 2,FLAG2 3,FLAG2 4,FLAG2 1 7,STATUS 6,STATUS 0,STATUS 1 1 4 2 1 1 1 1 4 1 0,TSFLAG 1,TSFLAG 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ;TEMP. ;LEFT TIME, RIGHT TIME ;LEFT WATCH COUNT ;RIGHT WATCH COUNT BUF. ;WATCH SET BUFFER ;TIME SET LEFT PM ;TIME SET RIGHT PM ;BLINK COUNTER 0~250 LOOP ;SET RPTEN(REPEAT KEY ENABLE) AFTER 1 SEC. ;KEYSCAN ;AT ONCE, KEY VALID ;MODE 3 (PORT TOGGLE) ;INSIDE & OUTSIDE TEMP. DUAL DISPLAY ;INSIDE TEMP or OUTSIDE TEMP.
A PUSH Y
;WTIMER ;LEFT TIME PM FLAG ;RIGHT TIME PM FLAG
PWMF DS 1 PERIOD EQU 0,PWMF ; ;************************************************************************** ; INTERRUPT VECTOR TABLE * ;**************************************************************************
xi
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
; ORG DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW 0FFE0H NOT_USED ; Timer-3 NOT_USED ; Timer-2 WTIMER ; Watch Timer INT_AD ; A/D CON. NOT_USED ; Serial I/O NOT_USED ; Not used NOT_USED ; Not used NOT_USED ; Int.2 TIMER1 ; Timer-1 TIMER0 ; Timer-0 INT1 ; Int.1 INT0 ; Int.0 NOT_USED; Watch Dog Timer NOT_USED; BIT INT_KEY ; Key Scan RESET ; Reset
; ;************************************************************************** ; MAIN PROGRAM * ;************************************************************************** ; ORG 0C000H ;Program Start Address ;ORG 0E000H ; 8K ROM VERSION ; RESET: LDM WDTR,#0 LDM RPR,#1 ; CLRG LDX #0 RAMCLR: LDA #0 ;RAM Clear(!0000H->!00BFH) STA {X}+ ;M(X) <- A, then X <- X+1 CMPX #0C0H ;X = #0C0H ? BNE RAMCLR SETG LDX #0 RAMCLR1: LDA #0 ;RAM Clear(!0100H->!011AH) STA {X}+ ;M(X) <- A, then X <- X+1 CMPX #1BH ;X = #01BH ? BNE RAMCLR1 CLRG ; LDX #0FFH ;Stack Pointer Initial TXSP ;SP. <- #0FFH ; ;******** USER RAM INITIALIZE ********** ; ; LDM MODE,#4 ; LDM SUBMODE,#1 SET1 LPM ;KST PM 12:00 JUST NOON LDM LHOUR,#12H LDM LMINUTE,#00H LDM RHOUR,#03H ;UTC AM 03:00 LDM RMINUTE,#00H SET1 OUTSIDE SET1 F_ON ;POWER ON ; ;********** PORT INITIALIZE ************ ; LDM LCDPM,#0 ;SEG0~SEG23 are used LDM R0,#0 ;I/O Port Data Clea LDM R1,#0 ;I/O Port Data Clear LDM R2,#0 LDM R3,#0 LDM R0DD,#1111_0001B ;R05,R06,R07: output for Keyscan LDM R1DD,#0000_0000B LDM R2DD,#0000_0000B ;R20~R23: input for keyscan LDM R3DD,#0000_0100B LDM R2PU,#0000_1111B ;R20~R23 pull-up active ; ;***** CONTROL REGISTER INITIALIZE ***** ; LDM CKCTLR,#0 ;WAKE UP TIME = 0.0625 sec ;(1/32768)*8*256 = 0.0625sec LDM TDR0,#249 ;8us x (249+1) = 2ms LDM TM0,#0000_1111B ;8BIT Timer,8us,Start Count-up LDM TDR1,#249 ;2us x (249+1) = 500us LDM TM1,#0000_1111B ;Timer1(8bit),32us,Start Count-up LDM TM3,#1010_1011B
APR. 2001 Ver 2.01
xii
GMS81C71XX LCD MCU APPENDIX
LDM LDM LDM LDM LDM LDM LDM LDM LDM LDM LDM LDM LDM EI ; BBC CALL CLR1
T3PPR,#99 T3PDR,#50 PWM1HR,#00H PMR,#80H IRQH,#0 IRQL,#0 IENL,#1111_1111B IENH,#1111_1111B IEDS,#0001_0101B KSMR,#0000_0001B WTMR,#48H LCDM,#70H SCMR,#0 ;Clear All Interrupts Requeat Flags ;INT2,ADC,WT,T2,T3 ;BIT,WDT,INT0,INT1,T0,T1 ;External Int. Falling edge select ;R10 KEY INTERRUPT ;ENABLE WT COUNTER, 2Hz, SELECT SUBCLOCK ;CLK=fsub/64, 1/4duty, internal Bias ;1/2, MAIN OSC. ;Enable Interrupts KEYONF,EXE1 KEYDECODE KEYONF ;TEST IF KEY IS PRESSED ;CLEAR KEY FLAG
LOOP: EXE1:
BBC F20MS,NEXT1 CLR1 F20MS ; ;*****EVERY 20MS***** ; CALL MODEEXE CALL MODE1EXE CALL MODE3EXE CALL LCDDGT CALL LCDDOT CALL ADCEXE CALL LKEYSCAN NEXT1: BBC F200MS,ELOOP CLR1 F200MS ; ;*****EVERY 200MS***** ; CALL WIND ELOOP: BBS F_ON,EXE2 CLR1 R0.7 CLR1 R0.6 CLR1 R0.5 CLR1 R0.4 STOP NOP NOP IF [F_1MIN] CLR1 F_1MIN CALL MODEEXE CALL LCDDGT CALL LCDDOT ENDIF CALL LKEYSCAN EXE2:
;SETTING DISPLAY MEMORY ;DURING CLOCK, ;7-Segments Display ;Dot Display ;ADC execution
;FOR ;FOR ;FOR ;FOR
WAKE-UP WAKE-UP WAKE-UP WAKE-UP
BY BY BY BY
NEXT NEXT NEXT NEXT
KEY KEY KEY KEY
;7-Segments Display ;Dot Display
JMP LOOP ; ;************************************************************************** ; TIMER0,INTERRUPT ROUTINE(2ms) * ;************************************************************************** ; TIMER0: R_SAVE ;Save Registers to Stacks CLRG CALL MAKE10MS ;SET every 10ms R_RSTR ;Restore Registers from Stacks RETI ; ;************************************************************************** ; TIMER1 * ;************************************************************************** ; TIMER1: R_SAVE CLRG R_RSTR
xiii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
RETI ; ;************************************************************************** ; WATCH TIMER 4Hz * ;************************************************************************** ; WTIMER: R_SAVE CLRG NOT1 R0.0 INC LDA CMP BNE LDM SET1 CALL WT5: R_RSTR RETI HZCNT HZCNT #120 WT5 HZCNT,#0 F_1MIN INC1MIN
; ;************************************************************************** ; PORT INTERRUPT * ;************************************************************************** ; INT_KEY: R_SAVE CLRG BBS CHATFL.7,IK8 BBS F_ON,IK8 LDX #3 LDM KSMR,#0 ;MAKE R10 TO BE NORMAL INPUT WW: WW2: WW3: LDY LDA DEC BNE DEC BNE LDA ROR BCS DEC BNE LDM SET1 SET1 LDM LDM R_RSTR RETI #2 #8 A WW3 Y WW2 R1 A IK8 X WW SCMR,#0 F_ON CHATFL.7 OLDKY,#0CH KSMR,#1 ;24ms wait
;READ R10
;MAIN OSC.
IK8:
; ;************************************************************************** ; EXTERNAL INTERRUPT 0 * ;************************************************************************** ; INT0: R_SAVE CLRG R_RSTR RETI ; ;************************************************************************** ; EXTERNAL INTERRUPT 1 * ;************************************************************************** ; INT1: CLRG RETI ; ;************************************************************************** ; ADC INTERRUPT * ;************************************************************************** ; INT_AD: RETI ; ;***********************************************************************
APR. 2001 Ver 2.01
xiv
GMS81C71XX LCD MCU APPENDIX
; Subject: LCDDGT ; LCD 7-SEG. DIGIT DISPLAY (TMEP,LTIME,RTIME * ;*********************************************************************** ; Entry: DGTCNT (DIGIT COUNTER) * ; X (START ADDRESS) * ; Output: Output SEG_PORT (SEG0~SEG23) * ; Output COM_PORT (COM0~COM3) * ;*********************************************************************** ; EXAMPLE) __ __ __ __ * ; DGTCNT=9 | || | | || | * ; X=LMINUTE |---| |---| |---| |---| * ; |___| |___| |___| |___| * ; LMINUTE+1 LMINUTE * ;*********************************************************************** ; LCDDGT: LDM DGTCNT,#9 LDX #DISPRAM GOLCD: LDA {X} PUSH X if [DGTCNT.0] ;WHEN DIGIT IS EVEN NUMBER, AND #0F0H ;WHEN DIGIT IS ODD NUMBER, XCN CALL LCDDSP ;HIGHER 4 NIBBLE IS DISPLAYED POP X else AND #0FH ;LOWER 4 NIBBLE IS DISPLAYED CALL LCDDSP POP X INC X endif DEC DGTCNT BPL GOLCD RET ; ;********* ONE DIGIT DISPLAY ********** ; LCDDSP: TAY ; ;****** ZERO SURPRESS TO BLANK ****** ; BNE GOCONT ;IF A=0 THEN SURPRESS LDA DGTCNT CMP #9 BEQ BLNK CMP #7 BEQ BLNK CMP #3 BEQ BLNK BRA GOCONT BLNK: LDY #0AH ; GOCONT: LDA !FONT+Y ;LOAD FONT DATA STA TEMP0 ;STORE 7-SEG FONT LDM TEMP2,#7 ;SHIFT COUNTER INITIALIZE LDY DGTCNT ;GET OFFSET LCD ADDRESS FOR DGTCNT LDA #14 MUL TAY DPL1: LDA !FONTD0+Y ;GET LCD RAM ADDRESS TAX ;STORE LCD RAM ADDRESS INC Y ;INCREMENT POINTER LDA !FONTD0+Y ;GET BIT POSITION STA TEMP1 ;STORE BIT POSITION ROR TEMP0 BCS DPL3 LDA #0FFH ;CLEAR BIT DISPLAY RAM ROL A DEC TEMP1 BPL $-3 SETG AND {X} BRA DPL5 DPL3: LDA #00H ;SET BIT DISPLAY RAM ROL A DEC TEMP1 BPL $-3 SETG OR {X} DPL5: STA {X}
xv
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
CLRG INC DBNE RET
Y TEMP2,DPL1
FONTD0 DB 13H,1H,13H,2H,13H,0H,13H,3H,0CH,3H,0CH,2H,0CH,0H ;RMINUTE0 FONTD1 DB 12H,1H,12H,2H,12H,0H,12H,3H,05H,3H,05H,2H,05H,0H ;RMINUTE1 FONTD2 DB 06H,1H,06H,2H,06H,0H,06H,3H,01H,3H,01H,2H,01H,0H ;RHOUR0 FONTD3 DB 80H,0H,01H,1H,01H,1H,80H,0H,80H,0H,80H,0H,80H,0H ;RHOUR1 FONTD4 DB 02H,1H,02H,2H,02H,0H,02H,3H,15H,3H,15H,2H,15H,0H ;LMINUTE0 FONTD5 DB 09H,1H,15H,1H,09H,0H,09H,3H,16H,0H,16H,1H,09H,2H ;LMINUTE1 FONTD6 DB 14H,1H,14H,2H,14H,0H,14H,3H,00H,3H,00H,2H,00H,0H ;LHOUR0 FONTD7 DB 80H,0H,08H,2H,08H,2H,80H,0H,80H,0H,80H,0H,80H,0H ;LHOUR1 FONTD8 DB 0BH,2H,0BH,0H,0BH,3H,0BH,1H,17H,1H,17H,0H,17H,3H ;ONDO0 FONTD9 DB 0FH,2H,0FH,0H,0FH,3H,0FH,1H,10H,1H,10H,0H,10H,3H ;ONDO1 ; ;************************************************************************** ; 7-SEGMENT PATTERN DATA * ; _a_ * ; f | g |b * ; |---| * ; e |___|c * ; d .h * ;************************************************************************** ; FONT Segment: DB DB DB DB DB DB DB DB DB DB DB DB EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU SETC STC STC STC STC LDCB STC LDCB STC LDC STC LDCB STC IF ldc stc ldcb stc ELSE LDCB STC 2,116H 2,10EH 2,107H 0,111H 1,10EH 0,10EH 1,108H 3,108H 1,104H 0,107H 2,10AH 3,10AH 3,104H _LCOLON _S1 _ONDO _C F_ON _SAVE DUAL_T _RCOLON LPM _LPM LPM _LAM [DUAL_T]==0 RPM _RPM RPM _RAM DUAL_T _RPM ;AM,PM SETTING hgfe dcba 0011_1111B 0000_0110B 0101_1011B 0100_1111B 0110_0110B 0110_1101B 0111_1101B 0000_0111B 0111_1111B 0110_1111B 0000_0000B 0100_0000B ; ; ; ; ; ; ; ; ; ; ; ; To be displayed Digit Number 0 1 2 3 4 5 6 7 8 9 A B "0"
"8" "9" "BLANK" "BAR"
_LCOLON _RCOLON _ONDO _C _RAM _RPM _LAM _LPM _OUTSIDE _INSIDE _S1 _SNOW _SAVE ; LCDDOT:
;TURN OFF THE AM, PM
APR. 2001 Ver 2.01
xvi
GMS81C71XX LCD MCU APPENDIX
STC ENDIF LDC STC LDCB STC
_RAM OUTSIDE _OUTSIDE OUTSIDE _INSIDE
RET ; ;*********************************************** ; Subject: ANY EXECUTION * ;*********************************************** ; DESCRIPTION: EVERY 20MS * ; * ;*********************************************** ; MODEEXE: IF [OUTSIDE] LDX #0 ELSE LDX #1 ENDIF LDA STA LDA STA IF IF ONDO+X DISPRAM SIGN+X DISPSIGN ;COPY ONDO DATA TO DISPRAM
[DISPSIGN.0] [DISPRAM] < #10 LDA #0B0H OR DISPRAM STA DISPRAM CLRC STC _SNOW ELSE SETC STC _SNOW ENDIF ELSE CLRC STC _SNOW ENDIF MX1: LDX LDA STA DEC BPL BBC LDA STA IF LDX ELSE LDX ENDIF LDA STA LDA ROR IF IF C #3 LHOUR+X DISPRAM1+X X MX1 DUAL_T,MX2 #0AAH DISPRAM1+2 [OUTSIDE] #1 #0 ONDO+X DISPRAM1+3 SIGN+X A
;IF MINUS ONDO, THEN "-" DISPLAY
;MOVE TIME_BUF. TO DISP_BUF.
;IF SINGLE TEMP. MODE, SKIP ;MAKE ERASE DISP BUF. WITCH ;WILL BE DISPLAYED TEMP. ;IF DUAL TEMP. MODE ;IF MAIN=OUSIDE, THEN SELECT INSIDE ;IF MAIN=INSIDE, THEN SELECT OUTSIDE
;GET BIT0 OF SIGN ;COPY SIGN TO CARRY ;IF MINUS ONDO, THEN "-" DISPLAY ;EXE) BB-4
[DISPRAM1+3] < #10 LDA #0B0H OR DISPRAM1+3 STA DISPRAM1+3 ELSE LDM DISPRAM1+2,#0ABH ENDIF ELSE IF [DISPRAM1+3] < #10 LDA #0A0H OR DISPRAM1+3 STA DISPRAM1+3 ENDIF
;EXE) B-14
;EXE) BB-4
xvii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
ENDIF MX2: RET
; ;*********************************************** ; Subject: MODE 1 EXECUTION * ;*********************************************** ; DESCRIPTION: CLOCK SET * ; * ;*********************************************** ; MODE1EXE: LDA MODE AND #0F0H CMP #10H ;IF MODE=1x BNE MB3 LDX #3 MB1: LDA TIMESET+X ;TIMESET BUF. COPIED TO DISP BUF. STA DISPRAM1+X ;4BYTE & 2 BIT DEC X BPL MB1 LDC TSLPM STC LPM LDC TSRPM STC RPM ; LDA MODE CMP #10H ;TEST IF LEFT TIME SET MODE ? BEQ MO10 CMP #11H BEQ MO11 ;TEST IF RIGHT TIME SET MODE ? BRA MB3 MO10: LDA CMP BCS LDA STA STA RET LDA CMP BCS LDA STA STA BRA BLINKCNT #125 MB3 #0AAH DISPRAM1 DISPRAM1+1 BLINKCNT #125 MB3 #0AAH DISPRAM1+2 DISPRAM1+3 MB3 ;IF LESS THAN 124, OFF
MB3: MO11:
;IF LESS THAN 124, OFF
; ;*********************************************** ; Subject: MODE 3 EXECUTION * ;*********************************************** ; DESCRIPTION: All pin goes low and high * ; repeatly every 20ms, rectangle wave output * ; * ;*********************************************** ; MODE3EXE: LDA MODE CMP #3 BNE MO2 LDA SUBMODE DEC A ;BECAUSE INITIAL NO.=1 ROL A ;EIGHT TIMES ROL A ROL A NOT1 TOGMO3 BBC TOGMO3,MO1 CLRC ADC #4 ;ADD OFFSET MO1: TAY LDA !PPORT+Y AND #0001_1111B OR R0BUF STA R0BUF STA R0 LDA !PPORT+1+Y STA R1 LDA !PPORT+2+Y STA R2
APR. 2001 Ver 2.01
xviii
GMS81C71XX LCD MCU APPENDIX
MO2: PPORT
LDA STA RET DB DB DB DB DB DB DB DB DB DB DB DB DB DB
!PPORT+3+Y R3 00H,00H,00H,00H 00H,00H,00H,00H 0FFH,0FFH,0FFH,0FFH 0FFH,0FFH,0FFH,0FFH 00H,00H,00H,00H 0FFH,0FFH,0FFH,0FFH 00H,00H,00H,00H 0FFH,00H,0FFH,00H 00H,0FFH,00H,0FFH 00H,00H,00H,00H 00H,0FFH,00H,0FFH 0FFH,00H,0FFH,00H 55H,55H,55H,55H 0AAH,0AAH,0AAH,0AAH
; ;*********************************************** ; Subject: Set falg at every 20ms * ;*********************************************** ; MAKE10MS: SETC LDA #0 ADC BSCTIME DAA STA BSCTIME BNE $+4 SET1 F200MS ;SET F200MS EVERY 200ms AND #0FH BNE $+4 SET1 F20MS ;SET F20MS EVERY 20ms ; INC BLINKCNT ;USED IN MODE0(CLOCK SET) LDA BLINKCNT CMP #250 BNE MZ1 LDM BLINKCNT,#0 MZ1: RET ; ;*********************************************** ; Subject: Analog to Digital Conversion * ;*********************************************** ; It is called in main routine every 20ms ADCNT DS 2 ADR_AVR DS 2 ADTTL DS 4 ADFLAG DS 1 AD_CH EQU 0,ADFLAG SIGN DS 2 DIVISOR EQU 250 ; ; :-------: :-------: ; :ADR_AVR: :ADR_AVR: ; : :: : ; :OUTSIDE: :INSIDE : ; :CH4 : :CH5 : ; :-------: :-------: ; ADCEXE: IF [AD_CH]== 0 LDM ADCM,#52H ;AD START CH4 LDX #0 ;SET TO 0 INDEX POINTER ELSE LDM ADCM,#56H ;AD START CH5 LDX #1 ;SET TO 1 INDEX POINTER ENDIF ADWAIT: LDY DEC BBS CMPY BNE #20 Y ADCM.0,GOGET #0 ADWAIT ;WAIT ADC END
xix
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
GOGET:
CLRC LDA ADR ADC ADTTL+X STA ADTTL+X LDA #0 ADC ADTTL+2+X STA ADTTL+2+X ; INC ADCNT+X LDA ADCNT+X IF A == #DIVISOR LDA #0 STA ADCNT+X LDY ADTTL+2+X LDA ADTTL+X PUSH X LDX #DIVISOR DIV POP X STA ADR_AVR+X LDA #0 STA ADTTL+X STA ADTTL+2+X LDA IF LDA ENDIF IF LDA ENDIF CMP ROL SETC SBC TAY LDA STA ENDIF ADR_AVR+X A < #65 #65 A > #240 #240 #181 SIGN+X #65 !ADTABLE1+Y ONDO+X AD_CH
;UP8 LO8 ;ADTTL2|ADTTL0 = CH4 DATA ;ADTTL3|ADTTL1 = CH5 DATA
;GET AVERAGE VALUE
;DIVIDE BY DIVISOR
;CLEAR SUM BUF.
;IGNORE BELOW 65 ;MAX. 240 ;MAKE SIGN ;COPY TO MINUS OR PLUS
ADCQUIT: ; ; ADTABLE
NOT1 RET DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB
ADTABLE1
50H,49H,49H,48H,48H,47H 47H,46H,46H,45H,45H,44H,44H,43H,43H,42H 41H,41H,40H,40H,40H,39H,39H,38H,38H,37H 37H,36H,36H,35H,35H,34H,34H,33H,33H,32H 32H,31H,31H,30H,30H,30H,29H,29H,28H,28H 27H,27H,26H,26H,25H,25H,24H,24H,24H,23H 23H,22H,22H,22H,21H,21H,20H,20H,20H,20H 19H,19H,18H,18H,17H,17H,16H,16H,15H,15H 15H,14H,14H,14H,13H,13H,13H,12H,12H,12H 11H,11H,11H,10H,10H,10H,09H,09H,09H,08H 08H,07H,07H,07H,06H,05H,05H,04H,04H,04H 03H,03H,02H,02H,01H,01H,00H,00H,00H,01H 01H,02H,02H,03H,03H,04H,04H,05H,05H,06H 06H,07H,07H,08H,08H,09H,09H,10H,10H,11H 11H,12H,12H,13H,13H,14H,15H,15H,16H,17H 17H,18H,18H,19H,19H,20H,20H,21H,21H,22H 23H,23H,24H,24H,25H,25H,26H,27H,28H,29H 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H 40H,41H,42H 50H,50H,50H,49H,49H,48H 48H,47H,47H,46H,46H,45H,45H,44H,44H,43H 43H,42H,41H,40H,39H,38H,37H,36H,35H,34H 35H,35H,34H,34H,33H,33H,32H,32H,31H,31H 30H,30H,29H,29H,28H,28H,27H,27H,26H,26H 26H,25H,25H,25H,24H,24H,24H,23H,23H,23H 22H,22H,22H,21H,21H,21H,20H,20H,20H,20H 19H,18H,18H,18H,17H,17H,17H,16H,16H,16H 15H,15H,15H,14H,14H,14H,13H,13H,13H,12H 12H,11H,11H,10H,10H,09H,09H,09H,08H,08H 07H,07H,06H,06H,05H,05H,04H,04H,04H,03H 03H,03H,02H,02H,02H,01H,01H,01H,00H,00H 01H,01h,02H,02H,03H,03H,04H,04H,05H,05H 06H,06H,07H,07H,08H,08H,09H,09H,10H,10H 11H,11H,12H,12H,13H,13H,14H,15H,15H,16H 16H,16H,17H,18H,18H,19H,19H,20H,20H,21H
; 65~ 70 ; 71~ 80 ; 81~ 90 ; 91~100 ;101~110 ;111~120 ;121~130 ;131~140 ;141~150 ;151~160 ;161~170 ;171~180 ;181~190 ;191~200 ;201~210 ;211~220 ;221~230 ;231~240 ; 65~ 70 ; 71~ 80 ; 81~ 90 ; 91~100 ;101~110 ;111~120 ;121~130 ;131~140 ;141~150 ;151~160 ;161~170 ;171~180 ;181~190 ;191~200 ;201~210 ;211~220
65->+50'C 83->+40'C 105->+30'C 129->+20'C 154->+10'C 178-> 0'C
199->-10'C 217->-20'C 231->-30'C 65->+50'C 83->+40'C 105->+30'C 129->+20'C 154->+10'C 178-> 0'C
199->-10'C 217->-20'C
APR. 2001 Ver 2.01
xx
GMS81C71XX LCD MCU APPENDIX
DB DB DB
21H,22H,23H,23H,24H,24H,25H,25H,26H,27H ;221~230 28H,29H,30H,31H,32H,33H,34H,35H,36H,37H ;231~240 231->-30'C 38H,39H,40H
; ;*********************************************** ; Subject: KEYDECODE * ;*********************************************** ; * ;*********************************************** ; REPEAT EQU #1000_0000B CLOCK EQU #0100_0000B PWRON EQU #0000_0001B KEYDECODE: LDA LDY MUL TAY LDA STA LDA STA LDA STA CALL BCC JMP ; KEY: DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB DW DB QUIT: NOKEY: RET CONDICHK: LDA OR SBC BEQ BCS SETC RET CLRC RET KEYDT #3 !KEY+Y TEMP0 !KEY+1+Y TEMP1 !KEY+2+Y TEMP2 CONDICHK QUIT [TEMP0] NOKEY 0 NOKEY 0 NOKEY 0 NOKEY 0 NOKEY 0 NOKEY 0 NOKEY 0 DOWNKEY PWRON+REPEAT NOKEY 0 DUALKEY PWRON SWAPKEY PWRON NOKEY 0 POWERKEY PWRON CLOCKKEY PWRON+CLOCK HOURKEY PWRON+REPEAT+CLOCK MINUTEKEY PWRON+REPEAT+CLOCK NOKEY 0 UPKEY PWRON+REPEAT NOKEY 0 ;0 ;1 ;2 ;3 ;4 ;5 ;6 ;7 ;8 ;9 ;A ;B ;C ;D ;E ;F ;10 ;11 ;12
TEMP2 STATUS TEMP2 CDC9 CDC10 ;PASS ;SKIP
CDC9: CDC10: ;
xxi
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
;*********************************************************** ; DISPLAY SWAP KEY (TEMP. DISPLAY SWAP) * ;*********************************************************** ; SWAPKEY: NOT1 OUTSIDE RET ; ;*********************************************************** ; DUAL KEY * ;*********************************************************** ; DUALKEY: NOT1 DUAL_T RET ; ;*********************************************************** ; POWER KEY * ;*********************************************************** ; POWERKEY: CLR1 F_ON IF [F_ON] ELSE LDM SCMR,#2 CLR1 DUAL_T LDM MODE,#0 SET1 F20MS ENDIF RET ; ;*********************************************************** ; CLOCK KEY * ;*********************************************************** ; CLOCKKEY: SET1 F_CLOCK LDM BLINKCNT,#0 LDA MODE ; 10->11 CMP #10H ; 11->00 BNE CL1 ; ETC. -> 10 LDM MODE,#11H BRA QUIT CL1: CMP #11H BNE CL2 LDM MODE,#0 CLR1 F_CLOCK CALL SETTO_CNT LDC TSLPM STC LPM LDC TSRPM STC RPM LDM HZCNT,#0 CLR1 F_1MIN BRA CLQ CL2: LDM CLR1 CALL LDC STC LDC STC RET MODE,#10H DUAL_T CNTTO_SET LPM TSLPM RPM TSRPM
CLQ: ; SETTO_CNT: LDX #3 CL11: LDA TIMESET+X STA LHOUR+X DEC X BPL CL11 RET ; CNTTO_SET: LDX #3 CL3: LDA LHOUR+X STA TIMESET+X DEC X BPL CL3 RET ; ;*********************************************************** ; HOUR/MINUTE KEY * ;*********************************************************** ; HOURKEY: LDA MODE
APR. 2001 Ver 2.01
xxii
GMS81C71XX LCD MCU APPENDIX
HO1: HO2:
AND #0F0H CMP #10H BNE HO1 LDM BLINKCNT,#125 LDA MODE CMP #10H BNE HO2 SETC LDA #0 ADC TIMESET DAA IF A==#12H NOT1 TSLPM ENDIF IF A==#13H LDA #1 ENDIF STA TIMESET RET CMP #11H BNE HO1 SETC LDA #0 ADC TIMESET+2 DAA IF A==#12H NOT1 TSRPM ENDIF IF A==#13H LDA #1 ENDIF STA TIMESET+2 BRA HO1 MODE #0F0H #10H MT3 BLINKCNT,#125 #3 MODE #10H MT1 #1 #0 TIMESET+X #60H MT2 #0 TIMESET+X
;IF MODE=10H, THEN LEFT TIME SET ;INC. LEFT HOUR 1UP
;ADJUST AM,PM FLAG
;INC. RIGHT HOUR 1UP
;ADJUST AM,PM FLAG
MINUTEKEY: LDA AND CMP BNE LDM LDX LDA CMP BNE LDX SETC LDA ADC DAA CMP BNE LDA STA RET
MT1:
MT2: MT3: ; ;*********************************************** ; UP /DOWN KEY * ;*********************************************** ; UPKEY: BBS PERIOD,PRU LDA PWM1HR AND #0000_0011B CMP #3 BNE UPK1 LDA T3PDR CMP #0FFH BNE UPK1 UPK0: RET UPK1: INC BNE INC BRA T3PDR UPK0 PWM1HR UPK0
PRU: DOWNKEY: BBS LDA AND CMP PERIOD,PRD PWM1HR #0000_0011B #0
xxiii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
DNK1:
DNK2: PRD:
BNE LDA CMP BEQ DEC LDA CMP BNE DEC RET
DNK1 T3PDR #0 UPK0 T3PDR T3PDR #0FFH DNK2 PWM1HR
PWMMODE: ; ;*********************************************************** ; PLUS KEY * ; * ; When MODE=3, PRESS PULS KEY, SUBMODE IS INCRESED * ; When MODE=3, PRESS MINUS KEY, SUBMODE IS DECRESED * ; * ;*********************************************************** ; ; ;*********************************************** ; Subject: KEYSCAN * ;*********************************************** ; STROBE OUT: R05,R06,R07 * ; READ PORT : R20,R21,R22,R23 * ; * ;*********************************************** ; LKEYSCAN: BBS KEYONF,KS7 LDM KEYNM,#1 LDM TOTLKY,#0 LDM NEWKY,#0 LDY #3 ;INITIALIZE STROBE LINE KS1: CMPY #3 BNE $+4 CLR1 R0.4 ;OUTPUT STROBE SIGNAL CMPY #2 BNE $+4 CLR1 R0.5 ;OUTPUT STROBE SIGNAL CMPY #1 BNE $+4 CLR1 R0.6 ;OUTPUT STROBE SIGNAL CMPY #0 BNE $+4 CLR1 R0.7 ;OUTPUT STROBE SIGNAL ; NOP NOP LDA R2 STA PORTDT ;READ KEY IN PORT AND #0FH CMP #0FH ;IF KEY IS PRESSED ? BNE KS2 CLRC ;KEYNM + 4 -> KEYNM LDA #4 ADC KEYNM STA KEYNM BRA KS5 ; KS2: LDX #3 ;INITIALIZE SHIFT COUNTER KS3: ROR PORTDT BCS KS4 INC TOTLKY ;IF TOTLKY IS ABOVE 2, THEN QUIT LDA TOTLKY CMP #20 BEQ KS7 LDA KEYNM ;KEYNM -> NEWKY STA NEWKY KS4: INC KEYNM DEC X BPL KS3 KS5: SET1 R0.4 SET1 R0.5
APR. 2001 Ver 2.01
xxiv
GMS81C71XX LCD MCU APPENDIX
KS6:
KS7: KS8:
KS81: KS9: KS10:
SET1 SET1 DEC BPL LDA CMP BNE LDA STA LDM CLR1 CLR1 CLR1 RET LDA CMP BNE BBS LDA AND CMP BCC LDA STA SET1 LDM SET1 BRA INC BRA LDA AND BBS CMP BCC SET1 BRA CMP BCC BBC SET1 BRA
R0.6 R0.7 Y KS1 NEWKY #0 KS8 NEWKY OLDKY CHATFL,#0 RPTKEY ACTKEY RPTEN NEWKY OLDKY KS6 CHATFL.7,KS10 CHATFL #0111_1111B #5 KS9 NEWKY KEYDT ACTKEY CHATFL,#80H KEYONF KS7 CHATFL KS7 CHATFL #0111_1111B RPTEN,KS11 #25 KS9 RPTEN KS81 #3 KS9 ACTKEY,KS7 RPTKEY KS81
;TEST NEXT LINE ;WHEN NO KEY IS PRESSED, ;INITIALIZE NEWKY,OLDKY,CHATFL
;SET1 CHATFL.7 & SET TO 0
;REPEAT KEY
KS11:
; ;*********************************************** ; Subject: Increase 1 minute * ;*********************************************** ; INC1MIN: LDX #LMINUTE CALL MIN1UP LDX #RMINUTE CALL MIN1UP RET ; MIN1UP: SETC LDA #0 ; LMINUTE <- LMINUTE + 1 ADC {X} DAA IF A ==#60H SETC LDA #0 ENDIF STA {X} BCC INC1 DEC X LDA #0 ADC {X} DAA IF A==#12H IF X==#LHOUR NOT1 LPM ELSE NOT1 RPM ENDIF ENDIF IF A==#13H LDA #1 ENDIF STA {X} INC1: RET
xxv
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
; ;*********************************************** ; Subject: WIND DISPLAY * ;*********************************************** ; WIND: LDA TEMPCNT CLRC STC 10DH.0 STC 10DH.1 STC 10DH.2 STC 10DH.3 CMP #0 BEQ LLL3 CMP #1 BEQ LLL2 CMP #2 BEQ LLL1 CMP #3 BEQ LLL0 CMP #4 BEQ LLL1 CMP #5 BEQ LLL2 CMP #6 BEQ LLL3 CMP #7 BEQ LLL4 LLL0: STC 10DH.1 LLL1: STC 10DH.2 LLL2: STC 10DH.3 LLL3: STC 10DH.0 LLL4: STC 111H.1 INC TEMPCNT IF [TEMPCNT]==#8 LDM TEMPCNT,#0 ENDIF RET ; ; ;************************************************************************** ; NOT_USED: nop ;Discard Unexpected Interrupts reti ; END ;Notice Program End
APR. 2001 Ver 2.01
xxvi


▲Up To Search▲   

 
Price & Availability of GMS87C7016K

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X